[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Terminate calling bash script upon receiving non zero return
From: |
Peng Yu |
Subject: |
[Help-bash] Terminate calling bash script upon receiving non zero return status (and possibly terminate calling script recursively) |
Date: |
Mon, 23 Apr 2012 09:41:05 -0500 |
Hi,
I'm looking for a feature that can terminate the calling bash script
if the called program return non zero status. But I don't find such a
feature.
I see that && is useful in the following. If prog1 is not returning
zero, prog2 will not be called.
prog1 && prog2
But this is not convenient if I need to calls many programs.
prog1 && prog2 .... && prog_n
is not as convenient as
prog1
prog2
...
prog_n
If I have some complex expressions, the way of '&&' makes them hard to read.
Also, if the calling script is called by another script, I want to
terminate that script as well.
Having to test the return status each time is one solution but it
requires writing a lot of testing code which I'd rather avoid.
Does anybody have any better solution?
--
Regards,
Peng
- [Help-bash] Terminate calling bash script upon receiving non zero return status (and possibly terminate calling script recursively),
Peng Yu <=