about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/options.yo8
-rw-r--r--Src/lex.c4
-rw-r--r--Test/A01grammar.ztst12
4 files changed, 26 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index c0fb29e8b..bcaab5c63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-02-21  Peter Stephenson  <pws@csr.com>
 
+	* 28783: Doc/Zsh/options.yo, Src/lex.c, Test/A01grammar.ztst:
+	allow ( to be treated specially in more places when SH_GLOB
+	is set but KSH_GLOB isn't.
+
 	* 28784: Doc/Zsh/options.yo, Test/A04redirect.ztst, Src/exec.c:
 	exit on exec redirection error with POSIXBUILTINS.
 
@@ -14238,5 +14242,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5204 $
+* $Revision: 1.5205 $
 *****************************************************
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 842e5c27b..4ecf8f831 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -683,8 +683,12 @@ item(tt(SH_GLOB) <K> <S>)(
 Disables the special meaning of `tt(LPAR())', `tt(|)', `tt(RPAR())'
 and 'tt(<)' for globbing the result of parameter and command substitutions,
 and in some other places where
-the shell accepts patterns.  This option is set by default if zsh is
-invoked as tt(sh) or tt(ksh).
+the shell accepts patterns.  If tt(SH_GLOB) is set but tt(KSH_GLOB) is
+not, the shell allows the interpretation of
+subshell expressions enclosed in parentheses in some cases where there
+is no space before the opening parenthesis, e.g. tt(!LPAR()true+RPAR())
+is interpreted as if there were a space after the tt(!).  This option is
+set by default if zsh is invoked as tt(sh) or tt(ksh).
 )
 pindex(UNSET)
 pindex(NO_UNSET)
diff --git a/Src/lex.c b/Src/lex.c
index 2988b41cb..8636a6fb4 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -877,7 +877,7 @@ gettok(void)
 		dbparens = 1;
 		return DINPAR;
 	    }
-	    if (incmdpos) {
+	    if (incmdpos || (isset(SHGLOB) && !isset(KSHGLOB))) {
 		len = 0;
 		bptr = tokstr = (char *) hcalloc(bsiz = 32);
 		switch (cmd_or_math(CS_MATH)) {
@@ -1141,6 +1141,8 @@ gettokstr(int c, int sub)
 		    break;
 		if (incasepat && !len)
 		    return INPAR;
+		if (!isset(KSHGLOB) && len)
+		    goto brk;
 	    }
 	    if (!in_brace_param) {
 		if (!sub) {
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index c8bf91cff..decab32b8 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -577,3 +577,15 @@
 0:$0 is traditionally if bizarrely set to the first argument with -c
 >myargzero
 >myargone
+
+  (setopt shglob
+  eval '
+  if ! (echo success1); then echo failure1; fi
+  if !(echo success2); then echo failure2; fi
+  print -l one two | while(read foo)do(print read it)done
+  ')
+0:Parentheses in shglob
+>success1
+>success2
+>read it
+>read it