Last active
October 8, 2019 17:18
-
-
Save JeffLabonte/4d3d506cbec351044c20965af63ac1eb to your computer and use it in GitHub Desktop.
This is the way arguments are to handled when you have many of them!
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 | |
--usage | --help | -h ) | |
usage_and_exit 0 | |
;; | |
--version | -v ) | |
version | |
exit 0 | |
;; | |
*) | |
error_and_usage "Unrecognized option: $1" | |
;; | |
esac | |
shift | |
done |
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
#!/bin/bash | |
while getopts "f:" OPTION | |
do | |
case $OPTION in | |
f) | |
MYOPTF="$MYOPTF $OPTARG" | |
echo MYOPTF | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment