Created
April 27, 2016 19:34
-
-
Save glts/18eb4512e65a3778c4838a113ea16aab to your computer and use it in GitHub Desktop.
Indispensable Bash script skeleton: never forget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Shell script skeleton. Try each of these: | |
# ./skeleton | |
# ./skeleton one | |
# ENVIRONMENTAL=x ./skeleton one | |
# ENVIRONMENTAL=x ./skeleton one two | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
readonly global=g | |
main() { | |
local -r required=$1 | |
local -r optional=${2:-default} | |
printf '<%s> <%s> <%s> <%s>\n' \ | |
"${ENVIRONMENTAL}" "${global}" "${required}" "${optional}" | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment