exit on error in bash
I have often cluttered my bash scripts with :
However the other day on hackernews I found this excellent article:
Shell script mistakes
There are many good nuggets of knowledge in it, but the one thing that I really liked was the simple fact that you do not have to check for errors after every command that could possible fail.
All you have to do is set -e
at the top of the script and if a command returns other than 0, the script will exit.