I prefer to write solid shell code, so the errexit & nounset is alway set.
The following code will stop at bad_command line
#!/bin/b
what if you want to know exit status of bad_command?
I think the simplest way is to disable errexit:
#!/bin/sh set -o errexit some_code_here set +o errexit bad_command status=$? set -o errexit process $status