[ILUG] Bash
John Tobin
tobinjt at netsoc.tcd.ie
Mon Jan 21 17:55:54 GMT 2002
On Mon, Jan 21, 2002 at 05:43:34PM +0000, Brendan Halpin wrote:
? Simple scripting question:
?
? With a bash script that runs a simple series of commands, how do I
? make it crash out if any one command fails, without filling it with
? conditionals?
?
? Pardon the ignorance, but I shell script too infrequently to
? accumulate knowledge.
set -e
From the bash manpage:
Exit immediately if a simple command (see SHELL GRAMMAR above) exits
with a non-zero status. The shell does not exit if the command that
fails is part of an until or while loop, part of an if statement, part
of a && or || list, or if the command's return value is being inverted
via !.
?
? Brendan
?
--
John
"That would preempt a bunch of problems involved in trying to reconstruct
exactly how the Perl 5 parser thinks, which nobody entirely understands."
Larry Wall, 2001/04/20, perl6-language at perl.org
"Finger to spiritual emptiness underlying everything." -- How a Japanese C
manual referred to a "pointer to void".
More information about the ILUG
mailing list