Use '' around declared values, and handle escaping in variable expansion.
This commit is contained in:
parent
a5b7c2345d
commit
a63a002c53
1 changed files with 2 additions and 4 deletions
|
|
@ -357,8 +357,6 @@ parse_ini() {
|
||||||
# Strip the []s and any whitespace between the []s and the section name.
|
# Strip the []s and any whitespace between the []s and the section name.
|
||||||
LINE="${LINE/#\[*([[:space:]])/}"
|
LINE="${LINE/#\[*([[:space:]])/}"
|
||||||
LINE="${LINE/%*([[:space:]])\]/}"
|
LINE="${LINE/%*([[:space:]])\]/}"
|
||||||
# LINE="${LINE/#*([[:blank:]])\[*([[:blank:]])/}"
|
|
||||||
# LINE="${LINE/%*([[:blank:]])\]*([[:blank:]])/}"
|
|
||||||
|
|
||||||
# Squash multiple consecutive blanks into a single space.
|
# Squash multiple consecutive blanks into a single space.
|
||||||
((SQUASH_SPACES == 1)) && LINE="${LINE//+([[:blank:]])/ }"
|
((SQUASH_SPACES == 1)) && LINE="${LINE//+([[:blank:]])/ }"
|
||||||
|
|
@ -474,9 +472,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" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$KEY" "$VALUE"
|
((CHECK_ONLY == 0)) && printf "%s%s%s[\"%s\"]='%s'\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$KEY" "${VALUE//\'/\'\\\'\'}"
|
||||||
else
|
else
|
||||||
((CHECK_ONLY == 0)) && printf "%s%s%s[\"%s\"]+=\"%s\"\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$CURRENT_SECTION" "$KEY" "$VALUE"
|
((CHECK_ONLY == 0)) && printf "%s%s%s[\"%s\"]+='%s'\\n" "$PREFIX" "${PREFIX:+$DELIM}" "$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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue