Link: Shell Scripting Tips

David Pashley writes a good post on various tips on making a more bullet proof shell script.

I use shell scripting from time to time, especially when bootstrapping EC2 instances, but more like a DOS batch script, and not really taking advantage of the wealth of flow control and error checking doodads that exist in the Bash environment.

I especially thought the exit if anything breaks trick was a good tip as I tend to write long automation scripts, that once something fails the rest of the statements will either fail or are irrelevant or cannot be trusted to have completed successfully. You accomplish this functionality by simply putting a single line at the top of your Bash script:

set -e

That's it! Check out the link to the post for more scripting goodness.