Created
December 19, 2018 20:51
-
-
Save hmil/53e340eaede6f4f429ff180303e120d0 to your computer and use it in GitHub Desktop.
Shell script stem
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
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