Suppose a shell script (/bin/sh or /bin/bash) contained several commands. How can I cleanly make the script terminate if any of the commands has a failing exit status? Obv
With standard sh and bash, you can
sh
bash
set -e
It will
$ help set ... -e Exit immediately if a command exits with a non-zero status.
It also works (from what I could gather) with zsh. It also should work for any Bourne shell descendant.
zsh
With csh/tcsh, you have to launch your script with #!/bin/csh -e
csh
tcsh
#!/bin/csh -e