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

scope of variables in loops



Hello,

Unlike bash, parameters that are set in loops on the command line
stick around.  It's not a big deal once you figure out what's going
on, but the code below can cause some head-scratching.  Is this
intended?  Is it controllable (is there a way to turn it off)?

Thanks,

Joey

zsh 4.3.6 (i386-portbld-freebsd7.0)% for ((x=0; x<=10; x++)) do echo "$x"; done
0
1
2
3
4
5
6
7
8
9
10

zsh 4.3.6 (i386-portbld-freebsd7.0)% for y in `ls *`; do echo $y; done
.Xauthority
.Xmodmap
.aspell.en.prepl
...
...

zsh 4.3.6 (i386-portbld-freebsd7.0)% for x in `ls *`; do echo $x; done
zsh: bad floating point constant

zsh 4.3.6 (i386-portbld-freebsd7.0)% unset x

zsh 4.3.6 (i386-portbld-freebsd7.0)% for x in `ls *`; do echo $x; done
0
1
2
3
4
5
6
7
8
9
10



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