summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-12-21 11:28:33 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-12-21 11:28:33 +0000
commit841e60c3408bc9b5eb679efd5cb4f7285cf799e8 (patch)
tree835950783704ccc23a8c81d069414ebe63d18e67
parenta9feb3b28acae7e27fdd9a4337192d6c0bc84a13 (diff)
downloadzsh-841e60c3408bc9b5eb679efd5cb4f7285cf799e8.tar.gz
zsh-841e60c3408bc9b5eb679efd5cb4f7285cf799e8.tar.xz
zsh-841e60c3408bc9b5eb679efd5cb4f7285cf799e8.zip
this prevent process-based features from working in their arguments
-rw-r--r--ChangeLog8
-rw-r--r--Src/parse.c6
-rw-r--r--Test/D03procsubst.ztst19
3 files changed, 30 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 78be78583..4eca500f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-12-21  Peter Stephenson  <pws@csr.com>
+
+	* 30930: Src/parse.c, Test/D03procsubst.ztst: anonymous
+	functions shouldn't be marked as simple; this prevented process
+	based features from working in their arguments.
+
 2012-12-20  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* unposted: Config/version.mk: zsh 5.0.1.
@@ -401,5 +407,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5776 $
+* $Revision: 1.5777 $
 *****************************************************
diff --git a/Src/parse.c b/Src/parse.c
index 0f5d99cef..753080d70 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -846,7 +846,7 @@ par_cmd(int *complex)
 	break;
     case FUNC:
 	cmdpush(CS_FUNCDEF);
-	par_funcdef();
+	par_funcdef(complex);
 	cmdpop();
 	break;
     case DINBRACK:
@@ -1420,7 +1420,7 @@ par_subsh(int *complex)
 
 /**/
 static void
-par_funcdef(void)
+par_funcdef(int *complex)
 {
     int oecused = ecused, num = 0, onp, p, c = 0;
     int so, oecssub = ecssub;
@@ -1471,6 +1471,7 @@ par_funcdef(void)
 	if (num == 0) {
 	    /* Anonymous function, possibly with arguments */
 	    incmdpos = 0;
+	    *complex = 1;
 	}
 	zshlex();
     } else if (unset(SHORTLOOPS)) {
@@ -1735,6 +1736,7 @@ par_simple(int *complex, int nr)
 		if (argc == 0) {
 		    /* Anonymous function, possibly with arguments */
 		    incmdpos = 0;
+		    *complex = 1;
 		}
 		zshlex();
 	    } else {
diff --git a/Test/D03procsubst.ztst b/Test/D03procsubst.ztst
index 602b1da15..88fa902bb 100644
--- a/Test/D03procsubst.ztst
+++ b/Test/D03procsubst.ztst
@@ -88,3 +88,22 @@
   print something=${:-=(echo 'C,D),(F,G)'}
 1: Graceful handling of bad substitution in enclosed context
 ?(eval):1: unterminated `=(...)'
+
+  () {
+     print -n "first: "
+     cat $1
+     print -n "second: "
+     cat $2
+  } =(echo This becomes argument one) =(echo and this argument two)
+  function {
+     print -n "third: "
+     cat $1
+     print -n "fourth: "
+     cat $2
+  } =(echo This becomes argument three) =(echo and this argument four)
+0:Process environment of anonymous functions
+>first: This becomes argument one
+>second: and this argument two
+>third: This becomes argument three
+>fourth: and this argument four
+