Skip to content

Instantly share code, notes, and snippets.

@sorensen
Created April 2, 2014 15:18
Show Gist options
  • Save sorensen/9936258 to your computer and use it in GitHub Desktop.
Save sorensen/9936258 to your computer and use it in GitHub Desktop.
Bash argv setup
APPLE=
BANANA=
CARROT=
DINOSAUR=false
ELEPHANT=false
while true; do
case "$1" in
-a | --apple ) APPLE=$2; shift 2 ;;
-b | --banana ) BANANA=$2; shift 2 ;;
-c | --carrot ) CARROT=$2; shift 2 ;;
-d | --dinosaur ) DINOSAUR=true; shift 1 ;;
-e | --elephant ) ELEPHANT=true; shift 1 ;;
-- ) shift; break ;;
* ) break ;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment