Skip to content

Instantly share code, notes, and snippets.

@mhuckaby
Created April 23, 2013 16:02
Show Gist options
  • Save mhuckaby/5444916 to your computer and use it in GitHub Desktop.
Save mhuckaby/5444916 to your computer and use it in GitHub Desktop.
Bash option idiom
while test $# -gt 0
do
case "$1" in
--opt1) echo "option 1"
;;
--opt2) echo "option 2"
;;
--*) echo "bad option $1"
;;
*) echo "argument $1"
;;
esac
shift
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment