Merge "Fix unsubstituted filename creation"

This commit is contained in:
Jenkins 2014-06-18 11:16:13 +00:00 committed by Gerrit Code Review
commit af86e43d7b
2 changed files with 36 additions and 4 deletions

View File

@ -82,8 +82,6 @@ function merge_config_file {
local matchgroup=$2
local configfile=$3
[[ -r $configfile ]] || touch $configfile
get_meta_section $file $matchgroup $configfile | \
$CONFIG_AWK_CMD -v configfile=$configfile '
BEGIN { section = "" }
@ -114,7 +112,7 @@ function merge_config_group {
for group in $matchgroups; 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
fi
done

View File

@ -42,6 +42,17 @@ type=original
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
[[test1|test1a.conf]]
[default]
@ -76,8 +87,11 @@ $TEST_1C_ADD
attribute=value
# 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: "
VAL=$(get_meta_section_files test.conf test0)
@ -192,4 +206,24 @@ EXPECT_VAL="
attribute = value"
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 -rf test-etc