Merge "Handle the case of pipe char in value for iniset"
This commit is contained in:
commit
998cc16a8d
@ -741,8 +741,9 @@ function iniset() {
|
||||
$option = $value
|
||||
" "$file"
|
||||
else
|
||||
local sep=$(echo -ne "\x01")
|
||||
# Replace it
|
||||
sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$value|" "$file"
|
||||
sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('${option}'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,26 @@ else
|
||||
echo "iniget failed: $VAL"
|
||||
fi
|
||||
|
||||
# test pipe in option
|
||||
iniset test.ini aaa handlers "a|b"
|
||||
|
||||
VAL=$(iniget test.ini aaa handlers)
|
||||
if [[ "$VAL" == "a|b" ]]; then
|
||||
echo "OK: $VAL"
|
||||
else
|
||||
echo "iniget failed: $VAL"
|
||||
fi
|
||||
|
||||
# test space in option
|
||||
iniset test.ini aaa handlers "a b"
|
||||
|
||||
VAL="$(iniget test.ini aaa handlers)"
|
||||
if [[ "$VAL" == "a b" ]]; then
|
||||
echo "OK: $VAL"
|
||||
else
|
||||
echo "iniget failed: $VAL"
|
||||
fi
|
||||
|
||||
# Test section not exist
|
||||
|
||||
VAL=$(iniget test.ini zzz handlers)
|
||||
|
Loading…
x
Reference in New Issue
Block a user