Skip to content

Commit 1ef6cad

Browse files
committed
Improved the check if argument passed section of the README
1 parent 0d44cfb commit 1ef6cad

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)