File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,9 @@ config_init() {
2020# Get a value from the config.
2121# Usage: result=$(config_get hello)
2222config_get () {
23- key=$1
24- regex=" ^$key *= *(.+)$"
23+ local key=$1
24+ local regex=" ^$key *= *(.+)$"
25+ local value=" "
2526
2627 config_init
2728
@@ -38,15 +39,16 @@ config_get() {
3839# Add or update a key=value pair in the config.
3940# Usage: config_set key value
4041config_set () {
41- key=$1
42+ local key=$1
4243 shift
43- value=" $* "
44+ local value=" $* "
4445
4546 config_init
4647
47- regex=" ^($key ) *= *.+$"
48- output=" "
49- found_key=" "
48+ local regex=" ^($key ) *= *.+$"
49+ local output=" "
50+ local found_key=" "
51+ local newline
5052
5153 while IFS= read -r line || [ -n " $line " ]; do
5254 newline=$line
@@ -69,15 +71,14 @@ config_set() {
6971# Delete a key from the config.
7072# Usage: config_del key
7173config_del () {
72- key=$1
74+ local key=$1
7375
74- regex=" ^($key ) *="
75- output=" "
76+ local regex=" ^($key ) *="
77+ local output=" "
7678
7779 config_init
7880
7981 while IFS= read -r line || [ -n " $line " ]; do
80- newline=$line
8182 if [[ $line ]] && [[ ! $line =~ $regex ]]; then
8283 output=" $output$line \n"
8384 fi
@@ -100,11 +101,13 @@ config_show() {
100101# done
101102#
102103config_keys () {
103- regex=" ^([a-zA-Z0-9_\-\/\.]+) *="
104+ local regex=" ^([a-zA-Z0-9_\-\/\.]+) *="
104105
105106 config_init
106107
107- keys=()
108+ local keys=()
109+ local key
110+
108111 while IFS= read -r line || [ -n " $line " ]; do
109112 if [[ $line =~ $regex ]]; then
110113 key=" ${BASH_REMATCH[1]} "
You can’t perform that action at this time.
0 commit comments