Skip to content

Instantly share code, notes, and snippets.

@iamJoeTaylor
Created July 8, 2015 21:27
Show Gist options
  • Save iamJoeTaylor/b2d1dfd6e99af25a1395 to your computer and use it in GitHub Desktop.
Save iamJoeTaylor/b2d1dfd6e99af25a1395 to your computer and use it in GitHub Desktop.
How to parse Args in Bash Exc
help() {
cat 1>&2 <<-USAGE
usage: $exe [options] [BRANCH]
USAGE GOES HERE
-h --help Show this message
-v --verbose Show URL before opening
-b --background Open page in the background
USAGE
}
for arg in "$@"; do
case $arg
in
-v | --verbose)
verbose=true
;;
-h | --help)
usage
exit
;;
-*)
echo "$0: unrecognized parameter '$arg'"
usage
exit 1
;;
*)
branch=$arg
;;
esac
done
usage() {
help
exit 1
}
die() {
echo 1>&2 "$1"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment