Use 's instead of "s when defining the array elements.
This commit is contained in:
parent
f7786946c0
commit
0b704e6ef1
1 changed files with 4 additions and 5 deletions
|
|
@ -93,7 +93,7 @@ parser_getopts() {
|
||||||
echo "${0##*/}: prefix (-p) cannot begin with a number" >&2
|
echo "${0##*/}: prefix (-p) cannot begin with a number" >&2
|
||||||
return 1
|
return 1
|
||||||
elif [[ "$2" =~ [^[:alnum:]_] ]]; then
|
elif [[ "$2" =~ [^[:alnum:]_] ]]; then
|
||||||
echo "${0##*/}: only alphanumerics and _ allowed for prefix (-p)" >&2
|
echo "${0##*/}: only alphanumerics and _ allowed for prefix (-p)" >&2
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
VARIABLE_PREFIX="$2"
|
VARIABLE_PREFIX="$2"
|
||||||
|
|
@ -450,7 +450,7 @@ parse_ini() {
|
||||||
((CHECK_ONLY == 0)) && printf "declare %s -A %s%s%s\\n" "$DECLARE_SCOPE" "$PREFIX" "$DELIM" "$CURRENT_SECTION"
|
((CHECK_ONLY == 0)) && printf "declare %s -A %s%s%s\\n" "$DECLARE_SCOPE" "$PREFIX" "$DELIM" "$CURRENT_SECTION"
|
||||||
SHOWN_SEC_HEAD=1
|
SHOWN_SEC_HEAD=1
|
||||||
fi
|
fi
|
||||||
((CHECK_ONLY == 0)) && printf "%s%s%s[\"%s\"]=\"%s\"\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$LINE" "$TEMP"
|
((CHECK_ONLY == 0)) && printf "%s%s%s['%s']='%s'\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$LINE" "$TEMP"
|
||||||
else
|
else
|
||||||
echo "${0##*/}: line $LINENUMBER: key without a value - skipping property" >&2
|
echo "${0##*/}: line $LINENUMBER: key without a value - skipping property" >&2
|
||||||
continue
|
continue
|
||||||
|
|
@ -499,9 +499,9 @@ parse_ini() {
|
||||||
|
|
||||||
# Output the associative array element definition.
|
# Output the associative array element definition.
|
||||||
if ((DUPLICATES_MERGE == 0)); then
|
if ((DUPLICATES_MERGE == 0)); then
|
||||||
((CHECK_ONLY == 0)) && printf "%s%s%s[\"%s\"]='%s'\\n" "$PREFIX" "$TEMP" "$CURRENT_SECTION" "$KEY" "${VALUE//\'/\'\\\'\'}"
|
((CHECK_ONLY == 0)) && printf "%s%s%s['%s']='%s'\\n" "$PREFIX" "$TEMP" "$CURRENT_SECTION" "$KEY" "${VALUE//\'/\'\\\'\'}"
|
||||||
else
|
else
|
||||||
((CHECK_ONLY == 0)) && printf "%s%s%s[\"%s\"]+='%s'\\n" "$PREFIX" "$TEMP" "$CURRENT_SECTION" "$KEY" "${VALUE//\'/\'\\\'\'}"
|
((CHECK_ONLY == 0)) && printf "%s%s%s['%s']+='%s'\\n" "$PREFIX" "$TEMP" "$CURRENT_SECTION" "$KEY" "${VALUE//\'/\'\\\'\'}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
((CHECK_ONLY == 1)) && echo "${0##*/}: line $LINENUMBER: skipping line" >&2
|
((CHECK_ONLY == 1)) && echo "${0##*/}: line $LINENUMBER: skipping line" >&2
|
||||||
|
|
@ -520,4 +520,3 @@ parse_ini() {
|
||||||
|
|
||||||
# If using the above functions in a script, adjust the call to 'parse_ini' below to use your chosen options.
|
# If using the above functions in a script, adjust the call to 'parse_ini' below to use your chosen options.
|
||||||
parse_ini "$@"
|
parse_ini "$@"
|
||||||
exit $?
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue