From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19518 invoked from network); 8 Oct 1997 03:25:01 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 8 Oct 1997 03:25:01 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id XAA15255; Tue, 7 Oct 1997 23:18:02 -0400 (EDT) Resent-Date: Tue, 7 Oct 1997 23:18:02 -0400 (EDT) From: "Bart Schaefer" Message-Id: <971007201754.ZM6858@candle.brasslantern.com> Date: Tue, 7 Oct 1997 20:17:54 -0700 In-Reply-To: <199710080047.TAA10231@ihnns581.ih.lucent.com> Comments: In reply to ramos@ih4ess.ih.lucent.com "this && that || the other && this too" (Oct 7, 7:47pm) References: <199710080047.TAA10231@ihnns581.ih.lucent.com> X-Mailer: Z-Mail (4.0b.820 20aug96) To: ramos@ih4ess.ih.lucent.com, zsh-workers@math.gatech.edu Subject: Re: this && that || the other && this too MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"3RoY9.0.Ik3.fjlEq"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3557 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Oct 7, 7:47pm, ramos@ih4ess.ih.lucent.com wrote: } Subject: this && that || the other && this too } } Apparently there is no way to construct an expression } using "&&" and "||" of the form: } } cmd1 XX cmd2 XX cmd3 } } such that both cmd2 and cmd3 execute when cmd1 succeeds, } and neither cmd2 nor cmd3 execute when cmd1 fails. Yes, that's correct. `&&' and `||' behave mostly like the boolean operators in C, so they execute exactly as many subexpressions, left to right, as are needed to determine the success or failure status of the entire expression. They differ from C in having equal precedence, so they evaluate strictly left to right unless grouped with ( ) or { }. This is distinct from `;' and `&' which execute both the left and right subexpressions regardless of the exit status of the left one. } "It would be nice" to be able to do this without using ()'s, or } if/then/fi, or some other contorted workaround. It would be confusing, is what it would be. What you want, it sounds like, is cmd1 && { cmd2 ; cmd3 } The only way to get that without the { } would be to introduce a new command separator that acted like `;' but that had higher precedence than `&&'. That behavior would be unlike any other separator in zsh or any other shell. There's nothing "contorted" about the { } form. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com