about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--Doc/Zsh/grammar.yo4
-rw-r--r--Doc/Zsh/options.yo27
-rw-r--r--Src/lex.c3
-rw-r--r--Src/options.c1
-rw-r--r--Src/zsh.h1
-rw-r--r--Test/E01options.ztst15
7 files changed, 55 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 78267c8e3..dc4fb2d3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-12-08  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 29955 with bits pointed out by Mikael and Bart:
+	Doc/Zsh/grammary.yo, Doc/Zsh/options.yo, Src/lex.c,
+	Src/options.c, Src/zsh.h, Test/E01options.ztst: add
+	IGNORE_CLOSE_BRACES option.
+
 2011-12-08  Peter Stephenson  <pws@csr.com>
 
 	* 29928: Test/A04redirect.ztst: belated commit to
@@ -15672,5 +15679,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5520 $
+* $Revision: 1.5521 $
 *****************************************************
diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo
index 5c803a681..30fec79c6 100644
--- a/Doc/Zsh/grammar.yo
+++ b/Doc/Zsh/grammar.yo
@@ -449,8 +449,8 @@ tt(do done esac then elif else fi for case
 if while function repeat time until
 select coproc nocorrect foreach end ! [[ { })
 
-Additionally, `tt(})' is recognized in any position if the tt(IGNORE_BRACES) option
-is not set.
+Additionally, `tt(})' is recognized in any position if neither the
+tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.
 texinode(Comments)(Aliasing)(Reserved Words)(Shell Grammar)
 sect(Comments)
 cindex(comments)
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 0e0176227..68247264f 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -548,7 +548,32 @@ cindex(disabling brace expansion)
 cindex(brace expansion, disabling)
 cindex(expansion, brace, disabling)
 item(tt(IGNORE_BRACES) (tt(-I)) <S>)(
-Do not perform brace expansion.
+Do not perform brace expansion.  For historical reasons this
+also includes the effect of the tt(IGNORE_CLOSE_BRACES) option.
+)
+pindex(IGNORE_CLOSE_BRACES)
+pindex(NO_IGNORE_CLOSE_BRACES)
+pindex(IGNORECLOSEBRACES)
+pindex(NOIGNORECLOSEBRACES)
+item(tt(IGNORE_CLOSE_BRACES))(
+When neither this option nor tt(IGNORE_BRACES) is set, a sole
+close brace character `tt(})' is syntactically significant at any
+point on a command line.  This has the effect that no semicolon
+or newline is necessary before the brace terminating a function
+or current shell construct.  When either option is set, a closing brace
+is syntactically significant only in command position.  Unlike
+tt(IGNORE_BRACES), this option does not disable brace expansion.
+
+For example, with both options unset a function may be defined
+in the following fashion:
+
+example(args() { echo $# })
+
+while if either option is set, this does not work and something
+equivalent to the following is required:
+
+example(args() { echo $#; })
+
 )
 pindex(KSH_GLOB)
 pindex(NO_KSH_GLOB)
diff --git a/Src/lex.c b/Src/lex.c
index 05f54f842..1cf3611c9 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1857,7 +1857,8 @@ exalias(void)
 
 	    /* Then check for a reserved word */
 	    if ((incmdpos ||
-		 (unset(IGNOREBRACES) && zshlextext[0] == '}' && !zshlextext[1])) &&
+		 (unset(IGNOREBRACES) && unset(IGNORECLOSEBRACES) &&
+		  zshlextext[0] == '}' && !zshlextext[1])) &&
 		(rw = (Reswd) reswdtab->getnode(reswdtab, zshlextext))) {
 		tok = rw->token;
 		if (tok == DINBRACK)
diff --git a/Src/options.c b/Src/options.c
index 00d552ad5..a70d4ff11 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -159,6 +159,7 @@ static struct optname optns[] = {
 {{NULL, "histverify",	      0},			 HISTVERIFY},
 {{NULL, "hup",		      OPT_EMULATE|OPT_ZSH},	 HUP},
 {{NULL, "ignorebraces",	      OPT_EMULATE|OPT_SH},	 IGNOREBRACES},
+{{NULL, "ignoreclosebraces",  0},			 IGNORECLOSEBRACES},
 {{NULL, "ignoreeof",	      0},			 IGNOREEOF},
 {{NULL, "incappendhistory",   0},			 INCAPPENDHISTORY},
 {{NULL, "interactive",	      OPT_SPECIAL},		 INTERACTIVE},
diff --git a/Src/zsh.h b/Src/zsh.h
index e3141120f..dda2fa91a 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2005,6 +2005,7 @@ enum {
     HISTVERIFY,
     HUP,
     IGNOREBRACES,
+    IGNORECLOSEBRACES,
     IGNOREEOF,
     INCAPPENDHISTORY,
     INTERACTIVE,
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index 1bbfdbda1..bcb34c352 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -256,6 +256,8 @@
 ?next one should fail
 ?(eval):1: parse error near `end'
 
+# ` emacs deconfusion
+
   setopt cshjunkiequotes
   print this should cause an error >&2
   eval "print 'line one
@@ -271,6 +273,8 @@
 ?(eval):1: unmatched '
 ?this should not
 
+# ' emacs deconfusion
+
   nullcmd() { print '$NULLCMD run'; }
   readnullcmd() { print 'Running $READNULLCMD'; cat; }
   NULLCMD=nullcmd
@@ -901,6 +905,8 @@
 ?(eval):exec:6: ls: restricted
 ?(eval):unsetopt:7: can't change option: restricted
 
+# ' emacs deconfusion
+
   fn() {
     print =ls ={ls,}
     local foo='=ls'
@@ -1081,3 +1087,12 @@
 ?+(eval):4> fn
 ?+fn:0> print message
 ?+(eval):5> unsetopt xtrace
+
+  setopt ignoreclosebraces
+  eval "icb_test() { echo this is OK; }"
+  icb_test
+  icb_args() { print $#; }
+  eval "icb_args { this, is, ok, too }"
+0:IGNORE_CLOSE_BRACES option
+>this is OK
+>6