Skip to content

Commit b47fdb1

Browse files
committed
Added code to look for the end of arguments marker
1 parent 34c4fa0 commit b47fdb1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

argument-parser.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ declare -A argExpected
1717
argExpected=()
1818
declare -a argChunks
1919
argChunks=()
20+
declare -a parameters
21+
parameters=()
2022

2123
lastWasArgument=0
2224
lastArgument=""
25+
endOfArguments=0
2326

2427
# Expand chained short form arguments, eg -aih => -a -i -h
2528
for argChunk in "$@"; do
@@ -161,6 +164,19 @@ argParse() {
161164
# Loop over all the argument chunks and determine if the argument type and value
162165
for argChunk in "${argChunks[@]}"; do
163166

167+
# Check if we've passed the last argument marker
168+
if [ $endOfArguments == 1 ]; then
169+
parameters+=("$argChunk")
170+
echo "#:$argChunk"
171+
continue
172+
fi
173+
174+
# Check if this chunk is the last argument marker
175+
if [ "$argChunk" == "--" ]; then
176+
endOfArguments=1
177+
continue;
178+
fi
179+
164180
# Check if this chunk is a short form argument
165181
[[ $argChunk =~ $regexArgShort ]]
166182
if [ "${BASH_REMATCH[1]}" != "" ]; then

0 commit comments

Comments
 (0)