I'm writing this all over the place:
if (( $x == 0 )) ; then
mycommand
x=$?
fi
Is there a simpler/briefer way to do this with bash's short-circuiting &&
?
EDIT:
I don't care about the value of $x
other than it's zeroness i.e. success/failure.
So, variable
x
is just the result of the previous command? If you mean that you have a continuous series of almost identical blocks like:Then, just combine your commands this way
[update]
On the other hand, if the commands are scattered all over the script, I would do either:
Or, more discreet:
Or, more probably, through a function: