mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
create-mskpec.sh: INI parsing -> ini-tools.sh
Push ini-parsing from create-mkspec.sh into ini-tools.sh. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
2572c931e1
commit
024b629859
2 changed files with 59 additions and 57 deletions
39
scripts/ini-tools.sh
Normal file
39
scripts/ini-tools.sh
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
ini_section()
|
||||
{
|
||||
local sec="$1"
|
||||
cat "$inifile" |
|
||||
cut -d\# -f1 |
|
||||
tr -s '\n' '\n' |
|
||||
sed -n "/\[$sec\]/,/\[/ p" |
|
||||
grep -v '\['
|
||||
}
|
||||
|
||||
ini_value()
|
||||
{
|
||||
local path=$1
|
||||
local sec=`echo $1 | sed 's/\.[^.]\+$//'`
|
||||
local key=`echo $1 | sed 's/.*\.//'`
|
||||
|
||||
# echo "path=>$path<"
|
||||
# echo "sec=>$sec<"
|
||||
# echo "key=>$key<"
|
||||
|
||||
if [ "$key" = "$path" ]; then
|
||||
ini_section $path
|
||||
return 0
|
||||
fi
|
||||
|
||||
ini_section $sec | sed "
|
||||
/^ *$key *=/ !d
|
||||
s/^ *$key *= *//
|
||||
s/ *$//
|
||||
"
|
||||
}
|
||||
|
||||
ini_escape()
|
||||
{
|
||||
cat | sed '
|
||||
s/\$/\\$/g
|
||||
s/`/\\\`/g
|
||||
'
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue