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

Math assignment to arrays: Is this a bug?



Try this but be prepared to interrupt it:

x=()
for (( x=1; x <= 10; x++ )) print $x

An infinite stream of "1" is the output.

Put "unset x" between the two lines of the example and it works fine.

Change the example to

x=()
for (( x=1; x <= 10; x++ )) typeset x

and you get an infinite stream of "x=(1)".

Why doesn't the assignment of 1 to x in the loop reset it from array to
scalar?



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