From: John Riddoch <jr@scms.rgu.ac.uk>
To: zsh-users@math.gatech.edu
Subject: Re: pipelines and &&
Date: Mon, 25 May 1998 11:46:04 +0100 (BST) [thread overview]
Message-ID: <199805251046.LAA07287@astar.scms.rgu.ac.uk> (raw)
> 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.
next reply other threads:[~1998-05-25 10:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-05-25 10:46 John Riddoch [this message]
-- strict thread matches above, loose matches on Subject: below --
1998-05-25 9:46 Matthias Kopfermann
1998-05-25 10:36 ` Thomas Koehler
1998-05-26 18:01 ` Matthias Kopfermann
1998-05-26 19:38 ` Bart Schaefer
1998-05-25 16:38 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199805251046.LAA07287@astar.scms.rgu.ac.uk \
--to=jr@scms.rgu.ac.uk \
--cc=zsh-users@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).