If we don't single quote the extracted argument to iniset we drop any
quotes from the source. Add a simple test-case for this.
Partial-bug: #1374118
Change-Id: If2f47b64b11015e727a011c7e5f6e8ad378b90eb
| ... | ... |
@@ -82,6 +82,8 @@ 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 |
|
| 85 | 87 |
get_meta_section $file $matchgroup $configfile | \ |
| 86 | 88 |
$CONFIG_AWK_CMD -v configfile=$configfile ' |
| 87 | 89 |
BEGIN { section = "" }
|
| ... | ... |
@@ -95,7 +97,7 @@ function merge_config_file {
|
| 95 | 95 |
} |
| 96 | 96 |
/^[^ \t]+/ {
|
| 97 | 97 |
split($0, d, " *= *") |
| 98 |
- print "iniset " configfile " " section " " d[1] " \"" d[2] "\"" |
|
| 98 |
+ print "iniset " configfile " " section " " d[1] " \x27" d[2] "\x27 " |
|
| 99 | 99 |
} |
| 100 | 100 |
' | while read a; do eval "$a"; done |
| 101 | 101 |
|
| ... | ... |
@@ -91,6 +91,10 @@ attribute=value |
| 91 | 91 |
[[test4|\$TEST4_DIR/\$TEST4_FILE]] |
| 92 | 92 |
[fff] |
| 93 | 93 |
type=new |
| 94 |
+ |
|
| 95 |
+[[test-quote|test-quote.conf]] |
|
| 96 |
+[foo] |
|
| 97 |
+foo="foo bar" "baz" |
|
| 94 | 98 |
EOF |
| 95 | 99 |
|
| 96 | 100 |
echo -n "get_meta_section_files: test0 doesn't exist: " |
| ... | ... |
@@ -206,6 +210,15 @@ EXPECT_VAL=" |
| 206 | 206 |
attribute = value" |
| 207 | 207 |
check_result "$VAL" "$EXPECT_VAL" |
| 208 | 208 |
|
| 209 |
+echo -n "merge_config_file test-quote: " |
|
| 210 |
+rm -f test-quote.conf |
|
| 211 |
+merge_config_file test.conf test-quote test-quote.conf |
|
| 212 |
+VAL=$(cat test-quote.conf) |
|
| 213 |
+EXPECT_VAL=' |
|
| 214 |
+[foo] |
|
| 215 |
+foo = "foo bar" "baz"' |
|
| 216 |
+check_result "$VAL" "$EXPECT_VAL" |
|
| 217 |
+ |
|
| 209 | 218 |
echo -n "merge_config_group test4 variable filename: " |
| 210 | 219 |
setup_test4 |
| 211 | 220 |
merge_config_group test.conf test4 |
| ... | ... |
@@ -225,5 +238,5 @@ EXPECT_VAL=" |
| 225 | 225 |
type = new" |
| 226 | 226 |
check_result "$VAL" "$EXPECT_VAL" |
| 227 | 227 |
|
| 228 |
-rm -f test.conf test1c.conf test2a.conf test-space.conf |
|
| 228 |
+rm -f test.conf test1c.conf test2a.conf test-quote.conf test-space.conf |
|
| 229 | 229 |
rm -rf test-etc |