Shell scripting: die on any error

With standard sh and bash, you can

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.

With csh/tcsh, you have to launch your script with #!/bin/csh -e

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)