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

Re: scope of variables in loops



On Jun 21,  5:57pm, Joey Mingrone wrote:
}
} Unlike bash, parameters that are set in loops on the command line
} stick around.

Peter's answer is nearly comprehensive, but I did want to point out
that "unlike bash" is incorrect here.

schaefer[503] bash
[schaefer@torch ~]$ for ((x=0; x<=10; x++)) do echo "$x"; done
0
1
2
3
4
5
6
7
8
9
10
[schaefer@torch ~]$ echo $x
11


The difference is not whether the *variable* "sticks around" but that the
implicit integer typedef sticks.



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