Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: For loop bug
- X-seq: zsh-workers 17676
- From: Philippe Troin <phil@xxxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: For loop bug
- Date: 15 Sep 2002 21:58:33 -0700
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <1020914045657.ZM12939@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20020913233156.324A31C0E9@xxxxxxxxxxxxxxxxxxxxxxxx> <871y7xs7yd.fsf@xxxxxxxxxxxxxxxx> <1020914045657.ZM12939@xxxxxxxxxxxxxxxxxxxxxxx>
- Sender: Philippe Troin <phil@xxxxxxxx>
"Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx> writes:
> On Sep 13, 5:58pm, Philippe Troin wrote:
> } Subject: Re: For loop bug
> }
> } Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx> writes:
> }
> } Does it fix this one as well?
> }
> } % for i in 1 2 3; do { {echo $i; [[ $i == 2 ]] && exit 1; } || break }; \
> } > done && echo X
> } 1
> } X
> } %
>
> That is not a bug.
>
> zagzig% [[ x == y ]] && true
> zagzig% echo $?
> 1
>
> Hence { [[ $i == 2 ]] && exit 1; } is false, and { false || break } means
> break. The && expression is only true if -both- branches are true.
Agreed.
> Further, { } is not a subshell, so { [[ 2 == 2 ]] && exit 1; } would most
> likely produce something like
>
> login:
>
> which might surprise you even more.
I'm not sure I get this part.
But shouldn't it print:
1
2
X
???
The echo $i with i set to 2 occurs before the exit and break
statements.
Phil.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author