File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ regexArgShortChained='^-([a-zA-Z0-9]{2,})$'
66regexArgLong=' ^--([a-zA-Z0-9\-]{2,})$'
77regexArgLongWithValue=' ^--([a-zA-Z0-9\-]{2,})=(.*)$'
88
9+ regexArgDefault=' ^([^=]+)=(.+) -'
10+
911argChunks=()
1012
1113# Expand chained short form arguments, eg -aih => -a -i -h
@@ -121,7 +123,24 @@ argValue() {
121123 fi
122124}
123125
126+ argParseDefaults () {
127+
128+ for arguments in " ${! argExpected[@]} " ; do
129+ [[ ${argExpected[$arguments]} =~ $regexArgDefault ]]
130+
131+ if [[ " ${BASH_REMATCH[@]} " == ' ' ]]; then
132+ continue ;
133+ fi
134+
135+ argv[" ${BASH_REMATCH[1]} " ]=" ${BASH_REMATCH[2]} "
136+ done
137+ }
138+
124139argParse () {
140+
141+ # Populate the argv array with the defaults
142+ argParseDefaults
143+
125144 # Loop over all the argument chunks and determine if the argument type and value
126145 for argChunk in " ${argChunks[@]} " ; do
127146
You can’t perform that action at this time.
0 commit comments