Skip to content

Commit 3343a64

Browse files
committed
Added a global_reset function which allows you to do a full reset after procssing an init file, so you can process more than one
1 parent 9a1e0d8 commit 3343a64

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

demos/parse-example.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ source "${SCRIPTPATH}"/src/ini-file-parser.sh
6363
# Tell the parser which ini file to process. #
6464
# -------------------------------------------------------------------------------- #
6565

66+
process_ini_file 'complete-example.conf'
67+
global_reset
6668
process_ini_file 'complete-example.conf'
6769

6870
# -------------------------------------------------------------------------------- #

src/ini-file-parser.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,20 @@ function unescape_string()
259259
echo "${orig}"
260260
}
261261

262+
# -------------------------------------------------------------------------------- #
263+
# Global Reset #
264+
# -------------------------------------------------------------------------------- #
265+
# Unset the global sections list, re-initialise it and reset the default section. #
266+
# -------------------------------------------------------------------------------- #
267+
268+
function global_reset()
269+
{
270+
unset sections
271+
sections=()
272+
273+
sections+=("${DEFAULT_SECTION}")
274+
}
275+
262276
# -------------------------------------------------------------------------------- #
263277
# Parse ini file #
264278
# -------------------------------------------------------------------------------- #

0 commit comments

Comments
 (0)