[ILUG] Bash
Sean
sean at binky.net
Mon Jan 21 18:21:10 GMT 2002
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
More information about the ILUG
mailing list