From 73ebca4fe92767665422e7fd5dc15032add389b4 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 21 Feb 2011 11:32:47 +0000 Subject: 28783: allow parentheses to be special in more places with SH_GLOB --- ChangeLog | 6 +++++- Doc/Zsh/options.yo | 8 ++++++-- Src/lex.c | 4 +++- Test/A01grammar.ztst | 12 ++++++++++++ 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 + * 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) )( 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 -- cgit 1.4.1