diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Doc/Zsh/grammar.yo | 2 | ||||
-rw-r--r-- | Doc/Zsh/options.yo | 8 | ||||
-rw-r--r-- | Src/lex.c | 2 | ||||
-rw-r--r-- | Src/options.c | 1 | ||||
-rw-r--r-- | Src/parse.c | 2 | ||||
-rw-r--r-- | Src/zsh.h | 1 | ||||
-rw-r--r-- | Test/E01options.ztst | 19 |
8 files changed, 34 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog index 0d43e8bae..09e89ceaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-04-02 Mikael Magnusson <mikachu@gmail.com> + + * 45142: Doc/Zsh/grammar.yo, Doc/Zsh/options.yo, Src/lex.c, + Src/options.c, Src/parse.c, Src/zsh.h, Test/E01options.ztst: + Add SHORT_REPEAT option + 2020-04-02 Daniel Shahaf <d.s@daniel.shahaf.name> * unposted: Test/D02glob.ztst: Make test platform-independent. diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo index fa0d72ff5..a4e0c1121 100644 --- a/Doc/Zsh/grammar.yo +++ b/Doc/Zsh/grammar.yo @@ -428,6 +428,8 @@ else the end of the test will not be recognized. For the tt(for), tt(repeat), tt(case) and tt(select) commands no such special form for the arguments is necessary, but the other condition (the special form of var(sublist) or use of the tt(SHORT_LOOPS) option) still applies. +The tt(SHORT_REPEAT) option is available to enable the short version only +for the tt(repeat) command. startitem() item(tt(if) var(list) tt({) var(list) tt(}) [ tt(elif) var(list) tt({) var(list) tt(}) ] ... [ tt(else {) var(list) tt(}) ])( diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index fdea51412..2b7637ff4 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -1377,6 +1377,14 @@ item(tt(SHORT_LOOPS) <C> <Z>)( Allow the short forms of tt(for), tt(repeat), tt(select), tt(if), and tt(function) constructs. ) +pindex(SHORT_REPEAT) +pindex(NO_SHORT_REPEAT) +pindex(SHORTREPEAT) +pindex(NOSHORTREPEAT) +item(tt(SHORT_REPEAT))( +Allow the short form tt(repeat) as tt(SHORT_LOOPS) but without enabling +it for the other constructs. +) pindex(SUN_KEYBOARD_HACK) pindex(NO_SUN_KEYBOARD_HACK) pindex(SUNKEYBOARDHACK) diff --git a/Src/lex.c b/Src/lex.c index 1d86da94e..a541defe6 100644 --- a/Src/lex.c +++ b/Src/lex.c @@ -270,7 +270,7 @@ zshlex(void) do { if (inrepeat_) ++inrepeat_; - if (inrepeat_ == 3 && isset(SHORTLOOPS)) + if (inrepeat_ == 3 && (isset(SHORTLOOPS) || isset(SHORTREPEAT))) incmdpos = 1; tok = gettok(); } while (tok != ENDINPUT && exalias()); diff --git a/Src/options.c b/Src/options.c index 08ba71917..7586d21d2 100644 --- a/Src/options.c +++ b/Src/options.c @@ -248,6 +248,7 @@ static struct optname optns[] = { {{NULL, "shnullcmd", OPT_EMULATE|OPT_BOURNE}, SHNULLCMD}, {{NULL, "shoptionletters", OPT_EMULATE|OPT_BOURNE}, SHOPTIONLETTERS}, {{NULL, "shortloops", OPT_EMULATE|OPT_NONBOURNE},SHORTLOOPS}, +{{NULL, "shortrepeat", OPT_EMULATE}, SHORTREPEAT}, {{NULL, "shwordsplit", OPT_EMULATE|OPT_BOURNE}, SHWORDSPLIT}, {{NULL, "singlecommand", OPT_SPECIAL}, SINGLECOMMAND}, {{NULL, "singlelinezle", OPT_KSH}, SINGLELINEZLE}, diff --git a/Src/parse.c b/Src/parse.c index 08919b2da..10c9b4c29 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -1593,7 +1593,7 @@ par_repeat(int *cmplx) if (tok != ZEND) YYERRORV(oecused); zshlex(); - } else if (unset(SHORTLOOPS)) { + } else if (unset(SHORTLOOPS) && unset(SHORTREPEAT)) { YYERRORV(oecused); } else par_save_list1(cmplx); diff --git a/Src/zsh.h b/Src/zsh.h index d72c338da..1f2d774a1 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -2508,6 +2508,7 @@ enum { SHNULLCMD, SHOPTIONLETTERS, SHORTLOOPS, + SHORTREPEAT, SHWORDSPLIT, SINGLECOMMAND, SINGLELINEZLE, diff --git a/Test/E01options.ztst b/Test/E01options.ztst index cfe2c75cc..70736f444 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -1109,15 +1109,22 @@ F:Regression test for workers/41811 eval 'for f (word1 word2) print $f' eval 'repeat 3 print nonsense' } - unsetopt shortloops - print option unset + unsetopt shortloops shortrepeat + print shortloops and shortrepeat unset + fn + setopt shortrepeat + print shortrepeat set fn setopt shortloops - print option set + print shortloops set fn 0:SHORT_LOOPS option ->option unset ->option set +>shortloops and shortrepeat unset +>shortrepeat set +>nonsense +>nonsense +>nonsense +>shortloops set >foo >bar >word1 @@ -1128,6 +1135,8 @@ F:Regression test for workers/41811 ?(eval):1: parse error near `print' ?(eval):1: parse error near `print' ?(eval):1: parse error near `print' +?(eval):1: parse error near `print' +?(eval):1: parse error near `print' fn() { print -l $*; } setopt shwordsplit |