I was wondering what would be the best way to check the exit status in an if statement in order to echo a specific output.
I\'m thinking of it being
Alternative to explicit if statement
if
Minimally:
test $? -eq 0 || echo "something bad happened"
Complete:
EXITCODE=$? test $EXITCODE -eq 0 && echo "something good happened" || echo "something bad happened"; exit $EXITCODE