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

Re: Short loops?



On Feb 26, 11:10am,  (Zoltan T. Hidvegi) wrote:
> Subject: Re: Short loops?
>
> So, the while syntax is not broken.  As you write above,
> while LIST { LIST } works.  But
> 
> while foo ; { bar }
> 
> is just while LIST because foo ; { bar } is a list in itself.  The above
> syntax only works if zsh can detect the end of the LIST before reading the
> {.

The doc ought to get changed, then.  The two entries for `while' (and
similarly for all the "short" variants) read:

`while LIST do LIST done'
`while LIST { LIST }'

The first and second uses of LIST both require either a newline or a
trailing semicolon; the fourth use of LIST may have a newline or a
semicolon or not, without affecting the result; and the third use
requires not only that there NOT be a newline or semicolon, but also
that the list ends with a [[ ]] (( )) ( ) or { } construct.

This is, if you ask me, completely bogus from a consistency standpoint,
not only in the doc but in the behavior; but its worse that the doc
makes it appear consistent when it isn't.

Furthermore, it's not just the case that zsh must be able to "detect
the end of the list before reading the {" because this:

	while true { echo foo }

doesn't work either, yet `true { ...' is in no sense a valid list.

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern



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