I have noticed there are two alternative ways of building loops in zsh:
for x (1 2 3); do echo $x; done
for 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?
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