From 3620e29e675305fc642f3a4472efd1d356c0fc5d Mon Sep 17 00:00:00 2001 From: albfan Date: Fri, 15 May 2015 18:42:31 +0200 Subject: [PATCH] better example file more verbose show all sections allow custom ini file --- scripts/example.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/scripts/example.sh b/scripts/example.sh index 9680b0a..1bfa6bd 100755 --- a/scripts/example.sh +++ b/scripts/example.sh @@ -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\""