I have noticed there are two alternative ways of building loops in zsh:
for x (1 2 3); do echo $x; donefor x in 1 2 3; do echo $x; done
They both print:
1
2
3
My question is, why the two syntaxes? Is $x iterating through a different type of object in each of them?
Does bash make a similar distinction?
Addendum:
Why does the following work?:
#!/bin/zsh
a=1
b=2
c=5
d=(a b c)
for x in $d; do print $x;done
but this one doesn't?:
#!/bin/zsh
a=1
b=2
c=5
d=(a b c)
# It complains with "parse error near `$d'"
for x $d; do print $x;done
for x ($d); do print $x; donewill work, and it will match the first syntax that you have enumerated at the beginning of your question. – Tim Kennedy Oct 25 '11 at 4:22