Created
April 23, 2013 16:02
-
-
Save mhuckaby/5444916 to your computer and use it in GitHub Desktop.
Bash option idiom
This file contains 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
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