Ceph for example uses them. Creation already worked, but not
updates of existing keys.
Closes-Bug: 1774956
Change-Id: I20cb61c08079b9cd9ad56ac875525abf1442bff6
| ... | ... |
@@ -200,7 +200,7 @@ $option = $value |
| 200 | 200 |
local sep |
| 201 | 201 |
sep=$(echo -ne "\x01") |
| 202 | 202 |
# Replace it |
| 203 |
- $sudo sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('${option}'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file"
|
|
| 203 |
+ $sudo sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('"${option}"'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file"
|
|
| 204 | 204 |
fi |
| 205 | 205 |
$xtrace |
| 206 | 206 |
} |
| ... | ... |
@@ -44,6 +44,9 @@ empty = |
| 44 | 44 |
multi = foo1 |
| 45 | 45 |
multi = foo2 |
| 46 | 46 |
|
| 47 |
+[key_with_spaces] |
|
| 48 |
+rgw special key = something |
|
| 49 |
+ |
|
| 47 | 50 |
# inidelete(a) |
| 48 | 51 |
[del_separate_options] |
| 49 | 52 |
a=b |
| ... | ... |
@@ -82,8 +85,9 @@ fi |
| 82 | 82 |
|
| 83 | 83 |
# test iniget_sections |
| 84 | 84 |
VAL=$(iniget_sections "${TEST_INI}")
|
| 85 |
-assert_equal "$VAL" "default aaa bbb ccc ddd eee del_separate_options \ |
|
| 86 |
-del_same_option del_missing_option del_missing_option_multi del_no_options" |
|
| 85 |
+assert_equal "$VAL" "default aaa bbb ccc ddd eee key_with_spaces \ |
|
| 86 |
+del_separate_options del_same_option del_missing_option \ |
|
| 87 |
+del_missing_option_multi del_no_options" |
|
| 87 | 88 |
|
| 88 | 89 |
# Test with missing arguments |
| 89 | 90 |
BEFORE=$(cat ${TEST_INI})
|
| ... | ... |
@@ -209,6 +213,20 @@ iniset $SUDO_ARG ${INI_TMP_ETC_DIR}/test.new.ini test foo bar
|
| 209 | 209 |
VAL=$(iniget ${INI_TMP_ETC_DIR}/test.new.ini test foo)
|
| 210 | 210 |
assert_equal "$VAL" "bar" "iniset created file" |
| 211 | 211 |
|
| 212 |
+# test creation of keys with spaces |
|
| 213 |
+iniset ${SUDO_ARG} ${TEST_INI} key_with_spaces "rgw another key" somethingelse
|
|
| 214 |
+VAL=$(iniget ${TEST_INI} key_with_spaces "rgw another key")
|
|
| 215 |
+assert_equal "$VAL" "somethingelse" "iniset created a key with spaces" |
|
| 216 |
+ |
|
| 217 |
+# test update of keys with spaces |
|
| 218 |
+iniset ${SUDO_ARG} ${TEST_INI} key_with_spaces "rgw special key" newvalue
|
|
| 219 |
+VAL=$(iniget ${TEST_INI} key_with_spaces "rgw special key")
|
|
| 220 |
+assert_equal "$VAL" "newvalue" "iniset updated a key with spaces" |
|
| 221 |
+ |
|
| 222 |
+inidelete ${SUDO_ARG} ${TEST_INI} key_with_spaces "rgw another key"
|
|
| 223 |
+VAL=$(iniget ${TEST_INI} key_with_spaces "rgw another key")
|
|
| 224 |
+assert_empty VAL "inidelete removed a key with spaces" |
|
| 225 |
+ |
|
| 212 | 226 |
$SUDO rm -rf ${INI_TMP_DIR}
|
| 213 | 227 |
|
| 214 | 228 |
report_results |