Skip to content

Commit 70d64fe

Browse files
committed
Moved the argExists and argValue functions to outside the argParse function
1 parent 17fb06f commit 70d64fe

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

argument-parser.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ argUnexpected() {
8484
echo "UNEXPECTED ARGUMENT $1"
8585
}
8686

87+
argExists() {
88+
if [ -z ${argv["$1"]+abc} ]; then
89+
return 1
90+
else
91+
return 0
92+
fi
93+
}
94+
95+
argValue() {
96+
if argExists "$1"; then
97+
echo "${argv["$1"]}"
98+
fi
99+
}
100+
87101
argParse() {
88102
# Loop over all the argument chunks and determine if the argument type and value
89103
for argChunk in "${argChunks[@]}"; do
@@ -186,20 +200,6 @@ argParse() {
186200
echo "ARG: $k = ${argv[$k]}"
187201
done
188202

189-
argExists() {
190-
if [ -z ${argv["$1"]+abc} ]; then
191-
return 1
192-
else
193-
return 0
194-
fi
195-
}
196-
197-
argValue() {
198-
if argExists "$1"; then
199-
echo "${argv["$1"]}"
200-
fi
201-
}
202-
203203
# Add the standard argc variable containing the number of arguments
204204
argc=${#argv[@]}
205205

0 commit comments

Comments
 (0)