From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28872 invoked from network); 16 Sep 2002 04:58:48 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 16 Sep 2002 04:58:48 -0000 Received: (qmail 18398 invoked by alias); 16 Sep 2002 04:58:39 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17676 Received: (qmail 18387 invoked from network); 16 Sep 2002 04:58:38 -0000 To: "Bart Schaefer" Cc: zsh-workers@sunsite.dk Subject: Re: For loop bug References: <20020913233156.324A31C0E9@pwstephenson.fsnet.co.uk> <871y7xs7yd.fsf@ceramic.fifi.org> <1020914045657.ZM12939@candle.brasslantern.com> From: Philippe Troin Date: 15 Sep 2002 21:58:33 -0700 In-Reply-To: <1020914045657.ZM12939@candle.brasslantern.com> Message-ID: <87elbufs3q.fsf@ceramic.fifi.org> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: Philippe Troin "Bart Schaefer" writes: > On Sep 13, 5:58pm, Philippe Troin wrote: > } Subject: Re: For loop bug > } > } Peter Stephenson 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.