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

Re: dangerous behavior of while in zsh 5.6 ?



hello,

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

> >     {   repeat 2 print $[i++]
> >         while (( i-- )) print $i
> >     } |sed 10 | xargs

> This shows a critical missing bit of detail from your original
> message:  The while loop is inside a { } expression.

the way i wrote it was only to demonstrate but this is another example:

    # grep -n . /tmp/a.zsh
    1:repeat 2 print $[i++]
    2:while ((i--))
    3:    print $i
    # zsh /tmp/a.zsh | sed 10q
    0
    1
    1
    0
    -1
    -2
    -3
    -4
    -5
    -6

regards
marc



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