Settings That Should be on Every Bash Script

When you really want a solid bash script, consider setting all of these options.

#!/bin/bash
#$URL$
#$Id$
 
#Enable debugging
#set -v
#set -x
 
#Exit if any undefined variable is used.
set -u
 
#Exit this script if it any subprocess exits non-zero.
set -e
 
#If any process in a pipeline fails, the return value is a failure.
set -o pipefail

Note that $URL$ and $Id$ are meant for subversion.

Your rating: None Average: 5 (1 vote)