From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15167 invoked from network); 25 May 1998 10:52:42 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 25 May 1998 10:52:42 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id GAA29693; Mon, 25 May 1998 06:46:56 -0400 (EDT) Resent-Date: Mon, 25 May 1998 06:45:23 -0400 (EDT) Message-Id: <199805251046.LAA07287@astar.scms.rgu.ac.uk> Date: Mon, 25 May 1998 11:46:04 +0100 (BST) From: John Riddoch Reply-To: John Riddoch Subject: Re: pipelines and && To: zsh-users@math.gatech.edu MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Content-MD5: zeDB6ImN2KJI+zdSNUEoMQ== X-Mailer: dtmail 1.2.0 CDE Version 1.2 SunOS 5.6 sun4m sparc Resent-Message-ID: <"aZ6rf.0.pD7.2lKQr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1546 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > I would very much like to know how sublists and pipelines are done: > I read the following without understanding how to do it: > > "If two pipelines are separated by ``&&'', the second > pipeline is executed only if the first is successful (returns a zero > value). If two pipelines are separated by ``||'', the second is > executed only if the first is unsuccessful (returns a nonzero value). > Both operators have equal precedence and are left associative." This has nothing to do with pipes; the term is probably somewhat confusing. A better example would be: cp file file.bak || echo "file not backed up" If the file could not be backed up (eg, the file does not exist or the user does not have write permission in the directory), then the error message is shown. Alternatively: cp file file.bak && echo "file backed up" || and && are alternatives to testing $? eg: cp file file.bak if [ $? = 0 ]; then echo "file backed up"; done is equivalent to the second example above. However, || and && are shorter and can be slightly more understandable. -- John Riddoch Email: jr@scms.rgu.ac.uk Telephone: (01224)262721 Room C6, School of Computer and Mathematical Science Robert Gordon University, Aberdeen, AB25 1HG And yeah, as I walk through the valley of the shadow of Death, I shall fear no evil, 'cause I'm packing an M60 with explosive ammo.