Shell Scripts

Advice from sharats:

Use .sh file extension.

Use long options where possible.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash

set -o errexit # Exit script on error
set -o nounset # Error accessing an unset variable
               # use "${VARNAME-}" for explicit optional vars
set -o pipefail # fail pipeline if any piped commands fail

# Enable debug mode via TRACE=1 ./script.sh
if  "${TRACE-0}" == "1" ; then
  set -o xtrace
fi

# If appropriate, switch to script's path before starting work
# cd "$(dirname "$0")"

main() {
    echo do awesome stuff
}

main "$@"