about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2013-12-06 09:47:28 +0200
committerPeter Stephenson <pws@zsh.org>2013-12-06 09:28:42 +0000
commitb28a6365f6ea5a9fdb8b63dd1612f55eb4034990 (patch)
treed439bf26b3ba376c2fa8d43eebf20b86f7e60ee4
parentc1a15fb1522b85a0780ce3f67ec1254115b18501 (diff)
downloadzsh-b28a6365f6ea5a9fdb8b63dd1612f55eb4034990.tar.gz
zsh-b28a6365f6ea5a9fdb8b63dd1612f55eb4034990.tar.xz
zsh-b28a6365f6ea5a9fdb8b63dd1612f55eb4034990.zip
32091: WARN_CREATE_GLOBAL false positive.
In cases like () { foo=bar =true; }
-rw-r--r--ChangeLog8
-rw-r--r--Src/exec.c5
-rw-r--r--Test/E01options.ztst17
3 files changed, 21 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index a44f54bf8..6f030d95a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-06  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* Daniel Shahaf: 32091: Src/exec.c, Test/E01options.ztst:
+	WARN_CREATE_GLOBAL false positive for assignment before
+	commands.
+
 2013-12-05  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* Daniel Shahaf: 32089:
@@ -39,7 +45,7 @@
 	Src/Modules/example.c, Src/module.c: Rationalise character
 	encodings: shell functions are strictly ASCII for maximum
 	portability; other files needed for building and documentation
-	are ASCII are UTF-8; test files may use ISO-8859-X (we don't
+	are ASCII or UTF-8; test files may use ISO-8859-X (we don't
 	require the Euro symbol) where needed to get single character
 	input with the top bit set.
 
diff --git a/Src/exec.c b/Src/exec.c
index df915e152..dccdc2b0d 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3309,7 +3309,10 @@ execcmd(Estate state, int input, int output, int how, int last1)
 	    }
 	    if (type == WC_SIMPLE) {
 		if (varspc) {
-		    addvars(state, varspc, ADDVAR_EXPORT|ADDVAR_RESTRICT);
+		    int addflags = ADDVAR_EXPORT|ADDVAR_RESTRICT;
+		    if (forked)
+			addflags |= ADDVAR_RESTORE;
+		    addvars(state, varspc, addflags);
 		    if (errflag)
 			_exit(1);
 		}
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index e00eb0e9c..d9f219115 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -83,12 +83,13 @@
 %prep
   mkdir options.tmp && cd options.tmp
 
-  mkdir tmpcd
+  mkdir tmpcd homedir
 
   touch tmpfile1 tmpfile2
 
   mydir=$PWD
   mydirt=`print -P %~`
+  mydirhome=`export HOME=$mydir/homedir; print -P %~`
   catpath=$(which cat)
   lspath==ls
 
@@ -513,10 +514,10 @@
   print *(#q:s/#(#b)tmp(*e)/'scrunchy${match[1]}'/)
   unsetopt histsubstpattern
 0:HIST_SUBST_PATTERN option
->TINGcd TINGfile1 TINGfile2
+>TINGcd TINGfile1 TINGfile2 homedir
 >THUMPcd THUMPfile1 THUMPfile2
 >one.c Two.X Three.X
->scrunchyfile1 scrunchyfile2 tmpcd
+>homedir scrunchyfile1 scrunchyfile2 tmpcd
 
   setopt ignorebraces
   echo X{a,b}Y
@@ -853,6 +854,7 @@
 
 # Do you have any idea how dull this is?
 
+  (export HOME=$mydir/homedir
   pushd $mydir/tmpcd
   pushd
   dirs
@@ -863,11 +865,11 @@
   popd
   pushd
   popd
-  dirs
+  dirs)
 0q:PUSHD_TO_HOME option
->$mydirt $mydirt/tmpcd
->~ $mydirt $mydirt/tmpcd
->$mydirt
+>$mydirhome $mydirhome/tmpcd
+>~ $mydirhome $mydirhome/tmpcd
+>$mydirhome
 
   array=(one two three four)
   setopt rcexpandparam
@@ -1067,6 +1069,7 @@
     fn2() {
       foo3=bar6
     }
+    foo4=bar7 =true
   }
   fn
 0:WARN_CREATE_GLOBAL option