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

Re: Parse error (lack thereof) on incomplete loops



On Fri, 5 Oct 2018 18:47:01 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > Without a "do" while doesn't know where the expression ends.  That's
> > fundamental to how SHORT_LOOPS works  
> 
> No it isn't.  The documentation explicitly says:
> 
>   For the if, while and until commands, in both these cases the test part
>   of the loop must also be suitably delimited, such as by `[[ ... ]]' or
>   `(( ... )), else the end of the test will not be recognized.
> 
> "Both these cases" refers to:
> #1 - sublist is of the form `{ list }'
> #2 - the SHORT_LOOPS option is set
> 
> So you don't get to claim that SHORT_LOOPS is intended to except you
> from that restriction.  The "]]" or "))" tell while where the
> expression ends.
> 
> In none of the examples given in this thread so far has the test
> expression been delimited that way.

But that's not what's implemented --- it just calls the code to parse
what the shell refers to as a "sublist", which is a component of the
normal parse tree.  There's never been any special short-loops code,
despite what the doc claims.  Hence there's no question, in general,
of throwing a syntax error if it isn't in the above form (unless
SHORT_LOOPS is unset).

I think the above is close to what Daniel is looking for --- a
statement of what does work, with anything else being left to
the user's peril.

It seems quite clear I should leave well alone.  If anyone thinks they
can write code that tightens it up in the above fashion, feel free.

pws



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