File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -26,17 +26,26 @@ Takes arguments passed in nearly any format to a bash script and allows easy acc
2626
2727### Check If An Argument Has Been Passed
2828
29- Check for the ` -v ` flag
29+ There is a helper function named ` argExists() ` which takes the name of
30+ an argument as its only parameter and returns a boolean.
3031
3132``` bash
32-
33+
34+ # -v
3335 if argExists ' v' ; then
34- echo " The -v flag has been passed"
36+ echo " The -v argument has been passed"
3537 fi
3638
37- # Or
39+ # -rMd
40+ argExists ' r' && echo " The -r argument was passed"
41+
42+ # --long-argument-name
43+ if argExists ' long-argument-name' ; then
44+ # Do something awesome
45+ fi
3846
39- argExists ' v' && echo " Verbosity Enabled"
47+ # -O 43
48+ argExists ' r' && echo " Found the -O argument"
4049
4150```
4251
You can’t perform that action at this time.
0 commit comments