1
0
mirror of https://github.com/albfan/bash-ini-parser.git synced 2025-08-10 16:22:59 +03:00

better example file

more verbose
show all sections
allow custom ini file
This commit is contained in:
albfan
2015-05-15 18:42:31 +02:00
parent d4da89a1be
commit 3620e29e67

View File

@@ -1,25 +1,34 @@
#!/bin/bash #!/bin/bash
TEST_FILE="${1:-file.ini}"
source ../bash-ini-parser source ../bash-ini-parser
TEST_FILE="file.ini" echo show example file
# parse the config file called 'file.ini' echo
cfg_parser "$TEST_FILE" cat $TEST_FILE
echo parsing $TEST_FILE
cfg_parser "$TEST_FILE"
echo
# show parsed ini file
echo show file parsed echo show file parsed
cfg_writer cfg_writer
echo echo
echo show some results echo show some results:
# enable section called 'sec2' (in the file [sec2]) for reading
echo
echo enable section \'sec2\'
cfg.section.sec2 cfg.section.sec2
# read the content of the variable called 'var2' (in the file
# var2=XXX). If your var2 is an array, then you can use
# ${var[index]}
echo "var2 value is \"$var2\"" echo "var2 value is \"$var2\""
echo "var5[1] value is \"${var5[1]}"\" echo "var5[1] value is \"${var5[1]}"\"
echo "var5[*] value is \"${var5[*]}"\" echo "var5[*] value is \"${var5[*]}"\"
echo "var4 value is \"$var4"\" echo "var4 value is \"$var4"\"
echo
echo enable section \'sec1\'
cfg.section.sec1
echo "var2 value is \"$var2\""