Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: scope of variables in loops
- X-seq: zsh-workers 25233
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "Joey Mingrone" <joey@xxxxxxxxxxxx>, zsh-workers@xxxxxxxxxx
- Subject: Re: scope of variables in loops
- Date: Sat, 21 Jun 2008 21:24:45 -0700
- In-reply-to: <f5b896260806211357r6d95026exf47a4a8ba68ec074@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <f5b896260806211357r6d95026exf47a4a8ba68ec074@xxxxxxxxxxxxxx>
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