Browse code

Merge "local.conf processing doesn't handle '=' in values"

Jenkins authored on 2014/10/14 08:12:36
Showing 2 changed files
... ...
@@ -96,8 +96,17 @@ function merge_config_file {
96 96
             next
97 97
         }
98 98
         /^[^ \t]+/ {
99
-            split($0, d, " *= *")
100
-            print "iniset " configfile " " section " " d[1] " \x27" d[2] "\x27 "
99
+            # get offset of first '=' in $0
100
+            eq_idx = index($0, "=")
101
+            # extract attr & value from $0
102
+            attr = substr($0, 1, eq_idx - 1)
103
+            value = substr($0, eq_idx + 1)
104
+            # only need to strip trailing whitespace from attr
105
+            sub(/[ \t]*$/, "", attr)
106
+            # need to strip leading & trailing whitespace from value
107
+            sub(/^[ \t]*/, "", value)
108
+            sub(/[ \t]*$/, "", value)
109
+            print "iniset " configfile " " section " " attr " \x27" value "\x27"
101 110
         }
102 111
     ' | while read a; do eval "$a"; done
103 112
 
... ...
@@ -95,6 +95,15 @@ type=new
95 95
 [[test-quote|test-quote.conf]]
96 96
 [foo]
97 97
 foo="foo bar" "baz"
98
+
99
+[[test5|test-equals.conf]]
100
+[DEFAULT]
101
+drivers = driver=python.import.path.Driver
102
+
103
+[[test6|test-strip.conf]]
104
+[DEFAULT]
105
+# next line has trailing space
106
+attr = strip_trailing_space 
98 107
 EOF
99 108
 
100 109
 echo -n "get_meta_section_files: test0 doesn't exist: "
... ...
@@ -238,5 +247,25 @@ EXPECT_VAL="
238 238
 type = new"
239 239
 check_result "$VAL" "$EXPECT_VAL"
240 240
 
241
-rm -f test.conf test1c.conf test2a.conf test-quote.conf test-space.conf
241
+echo -n "merge_config_file test5 equals in value: "
242
+rm -f test-equals.conf
243
+merge_config_file test.conf test5 test-equals.conf
244
+VAL=$(cat test-equals.conf)
245
+# iniset adds a blank line if it creates the file...
246
+EXPECT_VAL="
247
+[DEFAULT]
248
+drivers = driver=python.import.path.Driver"
249
+check_result "$VAL" "$EXPECT_VAL"
250
+
251
+echo -n "merge_config_file test6 value stripped: "
252
+rm -f test-strip.conf
253
+merge_config_file test.conf test6 test-strip.conf
254
+VAL=$(cat test-strip.conf)
255
+# iniset adds a blank line if it creates the file...
256
+EXPECT_VAL="
257
+[DEFAULT]
258
+attr = strip_trailing_space"
259
+check_result "$VAL" "$EXPECT_VAL"
260
+
261
+rm -f test.conf test1c.conf test2a.conf test-quote.conf test-space.conf test-equals.conf test-strip.conf
242 262
 rm -rf test-etc