[ale] bash question

J. D. jdonline at gmail.com
Sun Mar 26 10:52:13 EST 2006


I'm fairly new to bash scripting but do you think this would work? Use $? at
the key points in the script and if it does not equal zero it exits the
script? I think $? returns the exit status of the last command executed.

Best regards,

J. D.

On 3/26/06, David Corbin <dcorbin at machturtle.com> wrote:
>
> On Sunday 26 March 2006 08:22 am, Geoffrey wrote:
> > David Corbin wrote:
> > > I right my share of shell scripts, and I know how to check for the
> status
> > > of one command and terminate the script.
> > >
> > > I was wondering if there is a an option to bash to have it quit the
> > > script automatically when a command returns a non-zero status.  It
> would
> > > make some scripts much cleaner.
> >
> > What's wrong with something like:
> >
> > command || exit 1
>
> That's an improvement, no doubt, but it does require me to have a lot of
> duplication.
>
> foo || exit 1
> bar || exit 1
> gamma || exit 1
>
> etc.
>
> >
> > Or you could write yourself a shell function that's called on failure.
> > It would give you a single point of exit.
> >
> > Other then that, I don't think there's a way to do what you want.
>
> Perhaps not.  Just asking.
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list