You've already forked bash-ini-parser
mirror of
https://github.com/albfan/bash-ini-parser.git
synced 2025-08-09 05:22:44 +03:00
better example file
more verbose show all sections allow custom ini file
This commit is contained in:
@@ -1,25 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEST_FILE="${1:-file.ini}"
|
||||
|
||||
source ../bash-ini-parser
|
||||
|
||||
TEST_FILE="file.ini"
|
||||
# parse the config file called 'file.ini'
|
||||
cfg_parser "$TEST_FILE"
|
||||
echo show example file
|
||||
echo
|
||||
cat $TEST_FILE
|
||||
|
||||
echo parsing $TEST_FILE
|
||||
cfg_parser "$TEST_FILE"
|
||||
echo
|
||||
|
||||
# show parsed ini file
|
||||
echo show file parsed
|
||||
cfg_writer
|
||||
echo
|
||||
|
||||
echo show some results
|
||||
# enable section called 'sec2' (in the file [sec2]) for reading
|
||||
echo show some results:
|
||||
|
||||
echo
|
||||
echo enable 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 "var5[1] value is \"${var5[1]}"\"
|
||||
echo "var5[*] value is \"${var5[*]}"\"
|
||||
echo "var4 value is \"$var4"\"
|
||||
|
||||
echo
|
||||
echo enable section \'sec1\'
|
||||
cfg.section.sec1
|
||||
|
||||
echo "var2 value is \"$var2\""
|
||||
|
Reference in New Issue
Block a user