bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: feature request: more complete set -e


From: Greg Wooledge
Subject: Re: feature request: more complete set -e
Date: Tue, 30 Jun 2009 16:06:46 -0400
User-agent: Mutt/1.4.2.2i

On Tue, Jun 30, 2009 at 09:58:45PM +0200, Marc Weber wrote:
> How is this done?
> 
> CHK0="test $? == 0"
> my_important_task; $CHK0 || exit 1

You'd need single quotes instead of double there.  (And == is illegal in
Bourne/POSIX shell test commands; only bash tolerates it.)  You could
also use a function instead:

check() { test $? = 0; }
my_task; check || exit 1

Or, you could avoid the extra definition and simply check directly:

my_task || exit 1

my_task || { echo "error occurred" 1>&2; exit 1; }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]