Last active
July 13, 2017 16:30
-
-
Save gschueler/c59d27c3d2af26ed9268 to your computer and use it in GitHub Desktop.
bash template
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
#!/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