Skip to content

Instantly share code, notes, and snippets.

@robatwilliams
Created December 17, 2012 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robatwilliams/4318429 to your computer and use it in GitHub Desktop.
Save robatwilliams/4318429 to your computer and use it in GitHub Desktop.
Processing shell script options
unset OPTSTRING
unset OPTIND
local opt
while getopts "ab:c" opt; do
case $opt in
a)
aSpecified=true
;;
b)
bValue=$OPTARG
;;
c)
cSpecified=true
;;
?)
echo "Invalid option" > &2
esac
done
# shift along so we can get at the arguments
shift `expr $OPTIND - 1`
unset OPTSTRING
unset OPTIND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment