John Tobin wrote something:
{ 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
{ ?
{
If you yourself want to do the error checking, then after each command
check the $? variable. It's the status of the last command. If it's
non-zero then the last command had a error/problem of some kind.
Can help recover from an error rather than simply exit on error...
{ --
{ 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".
{
{ --
{ Irish Linux Users' Group: ilug at linux.ie
{ http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
{ List maintainer: listmaster at linux.ie
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!