Created
July 12, 2017 16:35
-
-
Save deanohyeah/1e2b433a4fbb8d9519610b1db7e4f9e7 to your computer and use it in GitHub Desktop.
Shell: example of optional flag parsing
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
# this function will search all passed arguments for optionalFlag's existence | |
function test() { | |
if [[ $* == *--optionalFlagt* ]] | |
then | |
do stuff | |
else | |
do other stuff | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment