Browse code

Merge "Fix unsubstituted filename creation"

Jenkins authored on 2014/06/18 20:16:13
Showing 2 changed files
... ...
@@ -82,8 +82,6 @@ function merge_config_file {
82 82
     local matchgroup=$2
83 83
     local configfile=$3
84 84
 
85
-    [[ -r $configfile ]] || touch $configfile
86
-
87 85
     get_meta_section $file $matchgroup $configfile | \
88 86
     $CONFIG_AWK_CMD -v configfile=$configfile '
89 87
         BEGIN { section = "" }
... ...
@@ -114,7 +112,7 @@ function merge_config_group {
114 114
 
115 115
     for group in $matchgroups; do
116 116
         for configfile in $(get_meta_section_files $localfile $group); do
117
-            if [[ -d $(dirname $configfile) ]]; then
117
+            if [[ -d $(dirname $(eval "echo $configfile")) ]]; then
118 118
                 merge_config_file $localfile $group $configfile
119 119
             fi
120 120
         done
... ...
@@ -42,6 +42,17 @@ type=original
42 42
 EOF
43 43
 }
44 44
 
45
+function setup_test4 {
46
+    mkdir -p test-etc
47
+    cat >test-etc/test4.conf <<EOF
48
+[fff]
49
+# original comment
50
+type=original
51
+EOF
52
+    TEST4_DIR="test-etc"
53
+    TEST4_FILE="test4.conf"
54
+}
55
+
45 56
 cat >test.conf <<EOF
46 57
 [[test1|test1a.conf]]
47 58
 [default]
... ...
@@ -76,8 +87,11 @@ $TEST_1C_ADD
76 76
 attribute=value
77 77
  
78 78
 # the above line has a single space
79
-EOF
80 79
 
80
+[[test4|\$TEST4_DIR/\$TEST4_FILE]]
81
+[fff]
82
+type=new
83
+EOF
81 84
 
82 85
 echo -n "get_meta_section_files: test0 doesn't exist: "
83 86
 VAL=$(get_meta_section_files test.conf test0)
... ...
@@ -192,4 +206,24 @@ EXPECT_VAL="
192 192
 attribute = value"
193 193
 check_result "$VAL" "$EXPECT_VAL"
194 194
 
195
+echo -n "merge_config_group test4 variable filename: "
196
+setup_test4
197
+merge_config_group test.conf test4
198
+VAL=$(cat test-etc/test4.conf)
199
+EXPECT_VAL="[fff]
200
+# original comment
201
+type=new"
202
+check_result "$VAL" "$EXPECT_VAL"
203
+
204
+echo -n "merge_config_group test4 variable filename (not exist): "
205
+setup_test4
206
+rm test-etc/test4.conf
207
+merge_config_group test.conf test4
208
+VAL=$(cat test-etc/test4.conf)
209
+EXPECT_VAL="
210
+[fff]
211
+type = new"
212
+check_result "$VAL" "$EXPECT_VAL"
213
+
195 214
 rm -f test.conf test1c.conf test2a.conf test-space.conf
215
+rm -rf test-etc