You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,6 +186,24 @@ The order the arguments are passed on the command line makes a difference
186
186
* Calling `my-script.sh -g 345 -g` will cause `argValue "g"` to return nothing
187
187
* Calling `my-script.sh --size 512 --size=1024` will cause `argValue "size"` to return `1024`
188
188
189
+
## Passing Additional Non-Arguments Strings
190
+
191
+
If you need to pass in non-argument stings along side your arguments you just need to add the end of arguments marker `--` and anything that follows wont be parsed as an argument but instead will be assigned to a numbered positional argument:
192
+
193
+
For example running: `./script.sh --arg1 --arg2 -- file1 file2 -f file5 fileN`
194
+
195
+
Will be parsed as:
196
+
197
+
* Argument: `--arg1`
198
+
* Argument: `--arg2`
199
+
* Non-Argument: `file1` (accessible via `$1`)
200
+
* Non-Argument: `file2` (accessible via `$2`)
201
+
* Non-Argument: `-f` (accessible via `$3`)
202
+
* Non-Argument: `file5` (accessible via `$4`)
203
+
* Non-Argument: `fileN` (accessible via `${N}`)
204
+
205
+
This way you can define arguments along side an arbitrary number of strings you may want to operate on at the same time!
206
+
189
207
## Debug Mode
190
208
191
209
There is a debug mode that can be enabled by setting the `ARG_DEBUG` variable to `true` right before including the library.
0 commit comments