This reverts commit e2c9fee8ed846aba124a2fc1bba245790ed7ba90.
We have decided that we don't want to support the json-style argument
as described by bug#1374118 (see thread at [1]).
This restores the old behavior of sending the argument in
double-quotes so environment variables get expanded. As a bonus,
tests for this are added.
[1] http://lists.openstack.org/pipermail/openstack-dev/2014-October/049341.html
Change-Id: I9fc99f3716cc53366907878adb00ae6cf3898f14
Closes-Bug:#1386413
| ... | ... |
@@ -82,8 +82,6 @@ function merge_config_file {
|
| 82 | 82 |
local matchgroup=$2 |
| 83 | 83 |
local configfile=$3 |
| 84 | 84 |
|
| 85 |
- # note in the awk below, \x27 is ascii for ' -- this avoids |
|
| 86 |
- # having to do nasty quoting games |
|
| 87 | 85 |
get_meta_section $file $matchgroup $configfile | \ |
| 88 | 86 |
$CONFIG_AWK_CMD -v configfile=$configfile ' |
| 89 | 87 |
BEGIN {
|
| ... | ... |
@@ -140,13 +138,13 @@ function merge_config_file {
|
| 140 | 140 |
for (attr_no = cfg_sec_attr_count[sno] - 1; attr_no >=0; attr_no--) {
|
| 141 | 141 |
attr = cfg_sec_attr_name[sno, attr_no] |
| 142 | 142 |
if (cfg_attr_count[section, attr] == 1) |
| 143 |
- print "iniset " configfile " " section " " attr " \x27" cfg_attr[section, attr, 0] "\x27" |
|
| 143 |
+ print "iniset " configfile " " section " " attr " \"" cfg_attr[section, attr, 0] "\"" |
|
| 144 | 144 |
else {
|
| 145 | 145 |
# For multiline, invoke the ini routines in the reverse order |
| 146 | 146 |
count = cfg_attr_count[section, attr] |
| 147 |
- print "iniset " configfile " " section " " attr " \x27" cfg_attr[section, attr, count - 1] "\x27" |
|
| 147 |
+ print "iniset " configfile " " section " " attr " \"" cfg_attr[section, attr, count - 1] "\"" |
|
| 148 | 148 |
for (l = count -2; l >= 0; l--) |
| 149 |
- print "iniadd_literal " configfile " " section " " attr " \x27" cfg_attr[section, attr, l] "\x27" |
|
| 149 |
+ print "iniadd_literal " configfile " " section " " attr " \"" cfg_attr[section, attr, l] "\"" |
|
| 150 | 150 |
} |
| 151 | 151 |
} |
| 152 | 152 |
} |
| ... | ... |
@@ -92,9 +92,9 @@ attribute=value |
| 92 | 92 |
[fff] |
| 93 | 93 |
type=new |
| 94 | 94 |
|
| 95 |
-[[test-quote|test-quote.conf]] |
|
| 95 |
+[[test-env|test-env.conf]] |
|
| 96 | 96 |
[foo] |
| 97 |
-foo="foo bar" "baz" |
|
| 97 |
+foo=\${FOO_BAR_BAZ}
|
|
| 98 | 98 |
|
| 99 | 99 |
[[test5|test-equals.conf]] |
| 100 | 100 |
[DEFAULT] |
| ... | ... |
@@ -126,9 +126,11 @@ cfg_item5 = 5555another |
| 126 | 126 |
|
| 127 | 127 |
[[test-multiline|test-multiline.conf]] |
| 128 | 128 |
[multi] |
| 129 |
-cfg_item1 = "ab":"cd", "ef": "gh" |
|
| 129 |
+cfg_item1 = ab:cd:ef:gh |
|
| 130 | 130 |
cfg_item1 = abcd |
| 131 | 131 |
cfg_item2 = efgh |
| 132 |
+cfg_item2 = \${FOO_BAR_BAZ}
|
|
| 133 |
+ |
|
| 132 | 134 |
EOF |
| 133 | 135 |
|
| 134 | 136 |
echo -n "get_meta_section_files: test0 doesn't exist: " |
| ... | ... |
@@ -236,14 +238,17 @@ check_result "$VAL" "$EXPECT_VAL" |
| 236 | 236 |
|
| 237 | 237 |
echo -n "merge_config_file test-multiline: " |
| 238 | 238 |
rm -f test-multiline.conf |
| 239 |
+FOO_BAR_BAZ="foo bar baz" |
|
| 239 | 240 |
merge_config_file test.conf test-multiline test-multiline.conf |
| 240 | 241 |
VAL=$(cat test-multiline.conf) |
| 241 | 242 |
EXPECT_VAL=' |
| 242 | 243 |
[multi] |
| 243 |
-cfg_item1 = "ab":"cd", "ef": "gh" |
|
| 244 |
+cfg_item1 = ab:cd:ef:gh |
|
| 244 | 245 |
cfg_item1 = abcd |
| 245 |
-cfg_item2 = efgh' |
|
| 246 |
+cfg_item2 = efgh |
|
| 247 |
+cfg_item2 = foo bar baz' |
|
| 246 | 248 |
check_result "$VAL" "$EXPECT_VAL" |
| 249 |
+unset FOO_BAR_BAZ |
|
| 247 | 250 |
|
| 248 | 251 |
echo -n "merge_config_group test2: " |
| 249 | 252 |
rm test2a.conf |
| ... | ... |
@@ -275,14 +280,16 @@ EXPECT_VAL=" |
| 275 | 275 |
attribute = value" |
| 276 | 276 |
check_result "$VAL" "$EXPECT_VAL" |
| 277 | 277 |
|
| 278 |
-echo -n "merge_config_file test-quote: " |
|
| 279 |
-rm -f test-quote.conf |
|
| 280 |
-merge_config_file test.conf test-quote test-quote.conf |
|
| 281 |
-VAL=$(cat test-quote.conf) |
|
| 278 |
+echo -n "merge_config_file test-env: " |
|
| 279 |
+rm -f test-env.conf |
|
| 280 |
+FOO_BAR_BAZ="foo bar baz" |
|
| 281 |
+merge_config_file test.conf test-env test-env.conf |
|
| 282 |
+VAL=$(cat test-env.conf) |
|
| 282 | 283 |
EXPECT_VAL=' |
| 283 | 284 |
[foo] |
| 284 |
-foo = "foo bar" "baz"' |
|
| 285 |
+foo = foo bar baz' |
|
| 285 | 286 |
check_result "$VAL" "$EXPECT_VAL" |
| 287 |
+unset FOO_BAR_BAZ |
|
| 286 | 288 |
|
| 287 | 289 |
echo -n "merge_config_group test4 variable filename: " |
| 288 | 290 |
setup_test4 |
| ... | ... |
@@ -332,6 +339,8 @@ EXPECT_VAL=" |
| 332 | 332 |
servers = 10.11.12.13:80" |
| 333 | 333 |
check_result "$VAL" "$EXPECT_VAL" |
| 334 | 334 |
|
| 335 |
-rm -f test.conf test1c.conf test2a.conf test-quote.conf test-space.conf test-equals.conf test-strip.conf test-colon.conf |
|
| 336 |
-rm -f test-multiline.conf test-multi-sections.conf |
|
| 335 |
+rm -f test.conf test1c.conf test2a.conf \ |
|
| 336 |
+ test-space.conf test-equals.conf test-strip.conf \ |
|
| 337 |
+ test-colon.conf test-env.conf test-multiline.conf \ |
|
| 338 |
+ test-multi-sections.conf |
|
| 337 | 339 |
rm -rf test-etc |