| ... | ... |
@@ -261,6 +261,18 @@ function iniuncomment {
|
| 261 | 261 |
$xtrace |
| 262 | 262 |
} |
| 263 | 263 |
|
| 264 |
+# Get list of sections from an INI file |
|
| 265 |
+# iniget_sections config-file |
|
| 266 |
+function iniget_sections {
|
|
| 267 |
+ local xtrace |
|
| 268 |
+ xtrace=$(set +o | grep xtrace) |
|
| 269 |
+ set +o xtrace |
|
| 270 |
+ local file=$1 |
|
| 271 |
+ |
|
| 272 |
+ echo $(sed -ne "s/^\[\(.*\)\]/\1/p" "$file") |
|
| 273 |
+ $xtrace |
|
| 274 |
+} |
|
| 275 |
+ |
|
| 264 | 276 |
# Restore xtrace |
| 265 | 277 |
$INC_CONF_TRACE |
| 266 | 278 |
|
| ... | ... |
@@ -80,6 +80,11 @@ if [ -n "$TEST_SUDO" ]; then |
| 80 | 80 |
sudo chown -R root:root ${INI_TMP_ETC_DIR}
|
| 81 | 81 |
fi |
| 82 | 82 |
|
| 83 |
+# test iniget_sections |
|
| 84 |
+VAL=$(iniget_sections "${TEST_INI}")
|
|
| 85 |
+assert_equal "$VAL" "default aaa bbb ccc ddd eee del_separate_options \ |
|
| 86 |
+del_same_option del_missing_option del_missing_option_multi del_no_options" |
|
| 87 |
+ |
|
| 83 | 88 |
# Test with missing arguments |
| 84 | 89 |
BEFORE=$(cat ${TEST_INI})
|
| 85 | 90 |
|