Skip to content

Instantly share code, notes, and snippets.

@gschueler
Last active July 13, 2017 16:30
Show Gist options
  • Save gschueler/c59d27c3d2af26ed9268 to your computer and use it in GitHub Desktop.
Save gschueler/c59d27c3d2af26ed9268 to your computer and use it in GitHub Desktop.
bash template
#!/bin/bash
#/ does something ...
#/ usage: [..]
set -euo pipefail
IFS=$'\n\t'
readonly ARGS=("$@")
# <http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/>
# <http://redsymbol.net/articles/unofficial-bash-strict-mode/>
usage() {
grep '^#/' <"$0" | cut -c4- # prints the #/ lines above as usage info
}
die(){
echo >&2 "$@" ; exit 2
}
check_args(){
: example to check args length
# if [ ${#ARGS[@]} -lt 1 ] ; then
# usage
# exit 2
# fi
}
# func(){
# local FARGS=("$@")
# # echo $FUNCNAME $@
# # set -x
# # do something
# # set -x
#}
main() {
check_args
# use local vars
#local i
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment