about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-09-11 12:49:05 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-09-11 12:49:05 +0000
commit8bb15c139248c9a4c4c0b2a053444e24ab8fc4f4 (patch)
tree46d30c5cf554f94d3aa883dc6b2f2e24ceab0a80
parentf95570c403aa073139c4b9fde5fd7c769d69fc6d (diff)
downloadzsh-8bb15c139248c9a4c4c0b2a053444e24ab8fc4f4.tar.gz
zsh-8bb15c139248c9a4c4c0b2a053444e24ab8fc4f4.tar.xz
zsh-8bb15c139248c9a4c4c0b2a053444e24ab8fc4f4.zip
25641: add emulation option (NO_)MULTI_FUNC_DEF
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/options.yo8
-rw-r--r--Src/options.c1
-rw-r--r--Src/parse.c3
-rw-r--r--Src/zsh.h1
5 files changed, 18 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 757c08faf..f2929793f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-11  Peter Stephenson  <pws@csr.com>
+
+	* 25641: add option (NO_)MULTI_FUNC_DEF to turn off "foo1
+	foo2...()" function definitions.
+
 2008-09-10  Clint Adams  <clint@zsh.org>
 
 	* Frank Terbeck: 25640: Completion/Unix/Command/_git: another alias
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index defb9c08c..5c7b29cfd 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1133,6 +1133,14 @@ fn+LPAR()RPAR() { setopt localtraps; trap '' INT; sleep 3; })
 
 will restore normally handling of tt(SIGINT) after the function exits.
 )
+pindex(MULTI_FUNC_DEF)
+item(tt(MULTI_FUNC_DEF) <Z>)(
+Allow definitions of multiple functions at once in the form `tt(fn1
+fn2)var(...)tt(LPAR()RPAR())'; if the option is not set, this causes
+a parse error.  Definition of multiple functions with the tt(function)
+keyword is always allowed.  Multiple function definitions are not often
+used and can cause obscure errors.
+)
 pindex(MULTIOS)
 item(tt(MULTIOS) <Z>)(
 Perform implicit bf(tee)s or bf(cat)s when multiple
diff --git a/Src/options.c b/Src/options.c
index 80e05b343..3c7f88048 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -181,6 +181,7 @@ static struct optname optns[] = {
 			      0
 #endif
 			      },			 MULTIBYTE},
+{{NULL, "multifuncdef",	      OPT_EMULATE|OPT_ZSH},	 MULTIFUNCDEF},
 {{NULL, "multios",	      OPT_EMULATE|OPT_ZSH},	 MULTIOS},
 {{NULL, "nomatch",	      OPT_EMULATE|OPT_NONBOURNE},NOMATCH},
 {{NULL, "notify",	      OPT_ZSH},			 NOTIFY},
diff --git a/Src/parse.c b/Src/parse.c
index 0812f9137..1b9a561e0 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1663,6 +1663,9 @@ par_simple(int *complex, int nr)
 	    zlong oldlineno = lineno;
 	    int onp, so, oecssub = ecssub;
 
+	    if (!isset(MULTIFUNCDEF) && argc > 1)
+		YYERROR(oecused);
+
 	    *complex = c;
 	    lineno = 0;
 	    incmdpos = 1;
diff --git a/Src/zsh.h b/Src/zsh.h
index 9326e1a11..1e043bf29 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1882,6 +1882,7 @@ enum {
     MENUCOMPLETE,
     MONITOR,
     MULTIBYTE,
+    MULTIFUNCDEF,
     MULTIOS,
     NOMATCH,
     NOTIFY,