Add copyright/license header. Add example usage to help.
This commit is contained in:
parent
a63a002c53
commit
9f284ef302
1 changed files with 12 additions and 1 deletions
13
parse_ini
13
parse_ini
|
|
@ -1,4 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Bash INI file parser v0.1.0.
|
||||||
|
# Copyright (C) 2019 Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>.
|
||||||
|
# Licensed under the terms of the GNU General Public Licence version 3.
|
||||||
|
#
|
||||||
|
# This program comes with ABSOLUTELY NO WARRANTY. For details and a full copy of
|
||||||
|
# the license terms, see: <http://gnu.org/licenses/gpl.html>. This is free
|
||||||
|
# software - you can modify and redistribute it under the terms of the GPL v3.
|
||||||
|
|
||||||
|
|
||||||
parser_getopts() {
|
parser_getopts() {
|
||||||
|
|
@ -132,11 +139,13 @@ parser_getopts() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
parser_help() {
|
parser_help() {
|
||||||
#........1.........2.........3.........4.........5.........6.........7.........8
|
#........1.........2.........3.........4.........5.........6.........7.........8
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
Usage: ${0##*/} [options] <INI file>
|
Usage: ${0##*/} [options] <INI file>
|
||||||
Parse an INI-style file into array assignments which can be 'eval'ed into Bash.
|
Parse an INI-style file into array assignments which can be 'eval'ed into Bash.
|
||||||
|
Example usage in bash script: eval "\$(${0##*/} example.ini)"
|
||||||
|
|
||||||
Commonly used options:
|
Commonly used options:
|
||||||
-b <char>, --bound <char>
|
-b <char>, --bound <char>
|
||||||
|
|
@ -215,6 +224,7 @@ parser_help() {
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
parser_version() {
|
parser_version() {
|
||||||
#........1.........2.........3.........4.........5.........6.........7.........8
|
#........1.........2.........3.........4.........5.........6.........7.........8
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
|
|
@ -229,7 +239,6 @@ parser_version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
parse_ini() {
|
parse_ini() {
|
||||||
# Bash v4.0+ is required.
|
# Bash v4.0+ is required.
|
||||||
if [[ -z "${BASH_VERSINFO[0]}" ]] || ((BASH_VERSINFO[0] < 4)); then
|
if [[ -z "${BASH_VERSINFO[0]}" ]] || ((BASH_VERSINFO[0] < 4)); then
|
||||||
|
|
@ -490,5 +499,7 @@ parse_ini() {
|
||||||
unset INIFILE
|
unset INIFILE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
parse_ini "$@"
|
parse_ini "$@"
|
||||||
exit $?
|
exit $?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue