Merge "Fix unsubstituted filename creation"
This commit is contained in:
@@ -82,8 +82,6 @@ function merge_config_file {
|
|||||||
local matchgroup=$2
|
local matchgroup=$2
|
||||||
local configfile=$3
|
local configfile=$3
|
||||||
|
|
||||||
[[ -r $configfile ]] || touch $configfile
|
|
||||||
|
|
||||||
get_meta_section $file $matchgroup $configfile | \
|
get_meta_section $file $matchgroup $configfile | \
|
||||||
$CONFIG_AWK_CMD -v configfile=$configfile '
|
$CONFIG_AWK_CMD -v configfile=$configfile '
|
||||||
BEGIN { section = "" }
|
BEGIN { section = "" }
|
||||||
@@ -114,7 +112,7 @@ function merge_config_group {
|
|||||||
|
|
||||||
for group in $matchgroups; do
|
for group in $matchgroups; do
|
||||||
for configfile in $(get_meta_section_files $localfile $group); do
|
for configfile in $(get_meta_section_files $localfile $group); do
|
||||||
if [[ -d $(dirname $configfile) ]]; then
|
if [[ -d $(dirname $(eval "echo $configfile")) ]]; then
|
||||||
merge_config_file $localfile $group $configfile
|
merge_config_file $localfile $group $configfile
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -42,6 +42,17 @@ type=original
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setup_test4 {
|
||||||
|
mkdir -p test-etc
|
||||||
|
cat >test-etc/test4.conf <<EOF
|
||||||
|
[fff]
|
||||||
|
# original comment
|
||||||
|
type=original
|
||||||
|
EOF
|
||||||
|
TEST4_DIR="test-etc"
|
||||||
|
TEST4_FILE="test4.conf"
|
||||||
|
}
|
||||||
|
|
||||||
cat >test.conf <<EOF
|
cat >test.conf <<EOF
|
||||||
[[test1|test1a.conf]]
|
[[test1|test1a.conf]]
|
||||||
[default]
|
[default]
|
||||||
@@ -76,8 +87,11 @@ $TEST_1C_ADD
|
|||||||
attribute=value
|
attribute=value
|
||||||
|
|
||||||
# the above line has a single space
|
# the above line has a single space
|
||||||
EOF
|
|
||||||
|
|
||||||
|
[[test4|\$TEST4_DIR/\$TEST4_FILE]]
|
||||||
|
[fff]
|
||||||
|
type=new
|
||||||
|
EOF
|
||||||
|
|
||||||
echo -n "get_meta_section_files: test0 doesn't exist: "
|
echo -n "get_meta_section_files: test0 doesn't exist: "
|
||||||
VAL=$(get_meta_section_files test.conf test0)
|
VAL=$(get_meta_section_files test.conf test0)
|
||||||
@@ -192,4 +206,24 @@ EXPECT_VAL="
|
|||||||
attribute = value"
|
attribute = value"
|
||||||
check_result "$VAL" "$EXPECT_VAL"
|
check_result "$VAL" "$EXPECT_VAL"
|
||||||
|
|
||||||
|
echo -n "merge_config_group test4 variable filename: "
|
||||||
|
setup_test4
|
||||||
|
merge_config_group test.conf test4
|
||||||
|
VAL=$(cat test-etc/test4.conf)
|
||||||
|
EXPECT_VAL="[fff]
|
||||||
|
# original comment
|
||||||
|
type=new"
|
||||||
|
check_result "$VAL" "$EXPECT_VAL"
|
||||||
|
|
||||||
|
echo -n "merge_config_group test4 variable filename (not exist): "
|
||||||
|
setup_test4
|
||||||
|
rm test-etc/test4.conf
|
||||||
|
merge_config_group test.conf test4
|
||||||
|
VAL=$(cat test-etc/test4.conf)
|
||||||
|
EXPECT_VAL="
|
||||||
|
[fff]
|
||||||
|
type = new"
|
||||||
|
check_result "$VAL" "$EXPECT_VAL"
|
||||||
|
|
||||||
rm -f test.conf test1c.conf test2a.conf test-space.conf
|
rm -f test.conf test1c.conf test2a.conf test-space.conf
|
||||||
|
rm -rf test-etc
|
||||||
|
|||||||
Reference in New Issue
Block a user