Skip to content

Commit b916db8

Browse files
committed
Added information to the README regarding passing non-argument strings
1 parent e172bc8 commit b916db8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ The order the arguments are passed on the command line makes a difference
186186
* Calling `my-script.sh -g 345 -g` will cause `argValue "g"` to return nothing
187187
* Calling `my-script.sh --size 512 --size=1024` will cause `argValue "size"` to return `1024`
188188

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+
189207
## Debug Mode
190208

191209
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

Comments
 (0)