Created
December 17, 2012 13:53
-
-
Save robatwilliams/4318429 to your computer and use it in GitHub Desktop.
Processing shell script options
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
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