Use 's instead of "s when defining the array elements.

This commit is contained in:
Darren 'Tadgy' Austin 2019-08-09 23:09:09 +01:00
commit 0b704e6ef1

View file

@ -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 $?