You've already forked bash-ini-parser
mirror of
https://github.com/albfan/bash-ini-parser.git
synced 2025-08-06 07:02:37 +03:00
operate by section
This commit is contained in:
@@ -61,9 +61,20 @@ function cfg_parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cfg_writer {
|
function cfg_writer {
|
||||||
|
SECTION=$1
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
IFS=' '$'\n'
|
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/}"
|
fun="${fun//declare -f/}"
|
||||||
for f in $fun; do
|
for f in $fun; do
|
||||||
[ "${f#$PREFIX}" == "${f}" ] && continue
|
[ "${f#$PREFIX}" == "${f}" ] && continue
|
||||||
@@ -135,9 +146,20 @@ function cfg_unset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cfg_clear {
|
function cfg_clear {
|
||||||
|
SECTION=$1
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
IFS=' '$'\n'
|
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/}"
|
fun="${fun//declare -f/}"
|
||||||
for f in $fun; do
|
for f in $fun; do
|
||||||
[ "${f#$PREFIX}" == "${f}" ] && continue
|
[ "${f#$PREFIX}" == "${f}" ] && continue
|
||||||
@@ -152,7 +174,7 @@ function cfg_update {
|
|||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
IFS=' '$'\n'
|
IFS=' '$'\n'
|
||||||
fun="$(declare -F $PREFIX$SECTION)"
|
fun="$(declare -F $PREFIX$SECTION)"
|
||||||
if [ -z $fun ]
|
if [ -z "$fun" ]
|
||||||
then
|
then
|
||||||
echo "section $SECTION not found" >2
|
echo "section $SECTION not found" >2
|
||||||
exit 1
|
exit 1
|
||||||
|
Reference in New Issue
Block a user