zsh-users
 help / color / mirror / code / Atom feed
* dangerous behavior of while in zsh 5.6 ?
@ 2018-10-03 14:38 Marc Chantreux
  2018-10-03 15:28 ` Bart Schaefer
  0 siblings, 1 reply; 11+ messages in thread
From: Marc Chantreux @ 2018-10-03 14:38 UTC (permalink / raw)
  Cc: Zsh-Users List

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-10-08 10:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 14:38 dangerous behavior of while in zsh 5.6 ? Marc Chantreux
2018-10-03 15:28 ` Bart Schaefer
2018-10-03 16:25   ` Marc Chantreux
2018-10-03 17:47     ` Daniel Shahaf
2018-10-03 20:47       ` nat() in pure shell Marc Chantreux
2018-10-03 22:08         ` Daniel Shahaf
2018-10-03 23:23           ` Marc Chantreux
2018-10-08 10:38           ` Vincent Lefevre
2018-10-04 15:50         ` Bart Schaefer
2018-10-03 20:54     ` dangerous behavior of while in zsh 5.6 ? Bart Schaefer
2018-10-03 21:06       ` Marc Chantreux

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).