Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: dangerous behavior of while in zsh 5.6 ?



On Wed, Oct 3, 2018 at 9:26 AM Marc Chantreux <eiro@xxxxxxxxx> wrote:
>
> i have the same behavior when interactive but no syntax error otherwise.
>
> instead:
>
>     {   repeat 2 print $[i++]
>         while (( i-- )) print $i
>     } |sed 10 | xargs

This shows a critical missing bit of detail from your original
message:  The while loop is inside a { } expression.  The parser
treats the close-brace as terminating the loop with an empty body.  If
this had been in a script file with end-of-file at that point, you
would have received the syntax error.

% { while false
cursh while> }
%

This potentially does indicate a parsing problem in 5.6, because in 5.0:

% { while false
cursh while> }
zsh: parse error near `}'



Messages sorted by: Reverse Date, Date, Thread, Author