29955++: IGNORE_CLOSE_BRACES option

This commit is contained in:
Peter Stephenson 2011-12-08 19:42:07 +00:00
parent 22aede45f6
commit e3182c18de
7 changed files with 55 additions and 5 deletions

View File

@ -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 $
*****************************************************

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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},

View File

@ -2005,6 +2005,7 @@ enum {
HISTVERIFY,
HUP,
IGNOREBRACES,
IGNORECLOSEBRACES,
IGNOREEOF,
INCAPPENDHISTORY,
INTERACTIVE,

View File

@ -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