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

Re: Short loops?



Bart Schaefer wrote:
> Nobody responded to my message to zsh-users about `while LIST { LIST }`
> syntax.  Is this syntax broken by accident or on purpose?

Sorry for the silence.  I've got a new job and moved to the US, that's why
I was a bit silent recently.  I'd like to buy a computer at home within a
few weeks and than I'll have more time to work on zsh again.

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

This works:

integer i=0
while ((i++ < 10)) { echo $i }

That's because ((i++ < 10)) { echo $i } is not a valid listso zsh can
detect that the list ends in )).  Similarily [[ ... ]] { ... } works as
well.  It is the same as

if [[ ... ]] then works without a semicolon before then but if true; then
doesn't.

Zoltan



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