Skip to content

Instantly share code, notes, and snippets.

@hmil
Created December 19, 2018 20:51
Show Gist options
  • Save hmil/53e340eaede6f4f429ff180303e120d0 to your computer and use it in GitHub Desktop.
Save hmil/53e340eaede6f4f429ff180303e120d0 to your computer and use it in GitHub Desktop.
Shell script stem
usage() {
echo "my-script.sh [options]"
echo ""
echo "Options:"
echo " --simple-param, -s : activate a feature"
echo " --complex-param, -c <value> : set some value"
echo " --help, -h : print this help message"
}
while [ "$1" != "" ]; do
case "$1" in
-h | --help)
usage
exit
;;
--simple-param|-s)
some_feature=true
;;
--complex-param|-c)
shift
some_data="$1"
;;
*)
echo "ERROR: unknown parameter \"$1\""
usage
exit 1
;;
esac
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment