about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2014-11-28 13:30:22 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2014-11-28 13:30:22 -0800
commit49d6aace41f5fe47abfaa87d25c42dbdb84dfb88 (patch)
tree9628c722c2fd505b081c5e61bdb448bef172b5f9
parent389954beec04f3019efa759ce92a4af85d24924e (diff)
downloadzsh-49d6aace41f5fe47abfaa87d25c42dbdb84dfb88.tar.gz
zsh-49d6aace41f5fe47abfaa87d25c42dbdb84dfb88.tar.xz
zsh-49d6aace41f5fe47abfaa87d25c42dbdb84dfb88.zip
33816, 33819: GLOB_ASSIGN changes integer and floating type variables to string scalars
-rw-r--r--ChangeLog8
-rw-r--r--Src/exec.c10
-rw-r--r--Test/A06assign.ztst20
3 files changed, 37 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a9de40d4..2a308a37e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-11-28  Barton E. Schaefer  <schaefer@brasslantern.com>
+
+	* 33819: Test/A06assign.ztst: regression tests for 33816
+
+	* 33816 (2nd part): Src/exec.c: GLOB_ASSIGN changes integer and
+	floating type variables to string scalars rather than treat single
+	match file names as arithmetic expressions
+
 2014-11-28  Wayne Davison  <wayned@users.sourceforge.net>
 
 	* unposted: avoid compiler warning about a set-but-not-used var.
diff --git a/Src/exec.c b/Src/exec.c
index 02a8fe3ad..2b7c55f8f 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2243,8 +2243,16 @@ addvars(Estate state, Wordcode pc, int addflags)
 		state->pc = opc;
 		return;
 	    }
-	    if (isset(GLOBASSIGN) || !isstr)
+	    if (!isstr || (isset(GLOBASSIGN) &&
+			   haswilds((char *)getdata(firstnode(vl))))) {
 		globlist(vl, 0);
+		/* Unset the parameter to force it to be recreated
+		 * as either scalar or array depending on how many
+		 * matches were found for the glob.
+		 */
+		if (isset(GLOBASSIGN))
+		    unsetparam(name);
+	    }
 	    if (errflag) {
 		state->pc = opc;
 		return;
diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst
index 9a0a4f0cc..3c9ea0837 100644
--- a/Test/A06assign.ztst
+++ b/Test/A06assign.ztst
@@ -1,5 +1,10 @@
 # Tests of parameter assignments
 
+%prep
+  mkdir assign.tmp && cd assign.tmp
+
+  touch tmpfile1 tmpfile2
+
 %test
 
  typeset -A assoc
@@ -413,3 +418,18 @@
 >world
 >worldliness
 >world
+
+ integer i n x
+ float f
+ setopt globassign
+ i=tmpfile1
+ n=tmp*
+ x=*2
+ f=2+2
+ typeset -p i n x f
+0:GLOB_ASSIGN with numeric types
+>typeset -i i=0
+>typeset -a n
+>n=(tmpfile1 tmpfile2)
+>typeset x=tmpfile2
+>typeset -E f=4.000000000e+00