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:
>   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.

Looked at this a bit more and I have fairly major doubts about the
documentation (although I don't mean about the intention suggested by
Bart which does seem reaonsble).

  The short versions below only work if var(sublist) is of the form `tt({)
  var(list) tt(})' or if the tt(SHORT_LOOPS) option is set.

For while and until, we only have
                     
 while list { list }
    An  alternative  form of while.  Note the limitations on the form of
    list mentioned above.
       
 until list { list }
    An alternative form of until.  Note the limitations on the  form  of
    list mentioned above.

No sublist.  The shortloops version of this does work:

while [[ -o shortloops ]] print yes

so maybe that "{ list }" should really be "sublist"?

It's also not clearly (or at all?  I can't se it) documented that you
only get the SHORT_LOOPS effect if there's no delimiter --- if you stick
one in it looks like a normal command list which it'll just go on parsing.

So actually I think the documentation here is defective even for the
cases of SHORT_LOOPS that *are* supposd to work.
 
Perhapse someone who may have to be Bart (I can't say I consider myself
an expert in this having only just found out what's going on and I can't
say anyone else is likely to, either) should suggest some words of
wisdom to document SHORT_LOOPS as separate text rather than as part of
the variant syntax section?  I don't mind writing this up.

pws



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