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

dangerous behavior of while in zsh 5.6 ?



hello people,

i switched to 5.6.2 and was really happy to see the
improvement of the alternative syntax.

thank you so much zsh-workers! i mean it! zsh is just awesome.

but there is an inconsistency in the behaviour that
is very dangerous and hard to easily spot in a large script:

a end of line after a condition is interpreted as an empty
true block so:

    while (( i-- ))
        print $i

should   mean:

    while (( i-- )) {print $i}

actually mean:

    while (( i-- )) {:}
    print $i

so it doesn't behave like the other loops:

    repeat 5 print $[i++]
    while (( i-- )) print $i

works ...

    repeat 5
        print $[i++]
    while (( i-- )) print $i

works ...

    repeat 5
        print $[i++]
    while (( i-- ))
        print $i

infinite loop. i think it's a bug. not sure :)

regards,
marc



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