1
0
mirror of https://github.com/albfan/bash-ini-parser.git synced 2025-08-04 19:42:06 +03:00

operate by section

This commit is contained in:
albfan
2015-05-16 20:37:43 +02:00
parent d0681d2421
commit f2c5703806

View File

@@ -61,9 +61,20 @@ function cfg_parser {
}
function cfg_writer {
SECTION=$1
OLDIFS="$IFS"
IFS=' '$'\n'
fun="$(declare -F)"
if [ -z "$SECTION" ]
then
fun="$(declare -F)"
else
fun="$(declare -F $PREFIX$SECTION)"
if [ -z "$fun" ]
then
echo "section $SECTION not found" >2
exit 1
fi
fi
fun="${fun//declare -f/}"
for f in $fun; do
[ "${f#$PREFIX}" == "${f}" ] && continue
@@ -135,9 +146,20 @@ function cfg_unset {
}
function cfg_clear {
SECTION=$1
OLDIFS="$IFS"
IFS=' '$'\n'
fun="$(declare -F)"
if [ -z "$SECTION" ]
then
fun="$(declare -F)"
else
fun="$(declare -F $PREFIX$SECTION)"
if [ -z "$fun" ]
then
echo "section $SECTION not found" >2
exit 1
fi
fi
fun="${fun//declare -f/}"
for f in $fun; do
[ "${f#$PREFIX}" == "${f}" ] && continue
@@ -152,7 +174,7 @@ function cfg_update {
OLDIFS="$IFS"
IFS=' '$'\n'
fun="$(declare -F $PREFIX$SECTION)"
if [ -z $fun ]
if [ -z "$fun" ]
then
echo "section $SECTION not found" >2
exit 1