Merge "Introduce iniget_sections function"

This commit is contained in:
Jenkins 2016-01-05 18:38:46 +00:00 committed by Gerrit Code Review
commit 119e36c921
2 changed files with 17 additions and 0 deletions

View File

@ -261,6 +261,18 @@ function iniuncomment {
$xtrace
}
# Get list of sections from an INI file
# iniget_sections config-file
function iniget_sections {
local xtrace
xtrace=$(set +o | grep xtrace)
set +o xtrace
local file=$1
echo $(sed -ne "s/^\[\(.*\)\]/\1/p" "$file")
$xtrace
}
# Restore xtrace
$INC_CONF_TRACE

View File

@ -80,6 +80,11 @@ if [ -n "$TEST_SUDO" ]; then
sudo chown -R root:root ${INI_TMP_ETC_DIR}
fi
# test iniget_sections
VAL=$(iniget_sections "${TEST_INI}")
assert_equal "$VAL" "default aaa bbb ccc ddd eee del_separate_options \
del_same_option del_missing_option del_missing_option_multi del_no_options"
# Test with missing arguments
BEFORE=$(cat ${TEST_INI})