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; }
