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() {
20
20
# Get a value from the config.
21
21
# Usage: result=$(config_get hello)
22
22
config_get () {
23
- key=$1
24
- regex=" ^$key *= *(.+)$"
23
+ local key=$1
24
+ local regex=" ^$key *= *(.+)$"
25
+ local value=" "
25
26
26
27
config_init
27
28
@@ -38,15 +39,16 @@ config_get() {
38
39
# Add or update a key=value pair in the config.
39
40
# Usage: config_set key value
40
41
config_set () {
41
- key=$1
42
+ local key=$1
42
43
shift
43
- value=" $* "
44
+ local value=" $* "
44
45
45
46
config_init
46
47
47
- regex=" ^($key ) *= *.+$"
48
- output=" "
49
- found_key=" "
48
+ local regex=" ^($key ) *= *.+$"
49
+ local output=" "
50
+ local found_key=" "
51
+ local newline
50
52
51
53
while IFS= read -r line || [ -n " $line " ]; do
52
54
newline=$line
@@ -69,15 +71,14 @@ config_set() {
69
71
# Delete a key from the config.
70
72
# Usage: config_del key
71
73
config_del () {
72
- key=$1
74
+ local key=$1
73
75
74
- regex=" ^($key ) *="
75
- output=" "
76
+ local regex=" ^($key ) *="
77
+ local output=" "
76
78
77
79
config_init
78
80
79
81
while IFS= read -r line || [ -n " $line " ]; do
80
- newline=$line
81
82
if [[ $line ]] && [[ ! $line =~ $regex ]]; then
82
83
output=" $output$line \n"
83
84
fi
@@ -100,11 +101,13 @@ config_show() {
100
101
# done
101
102
#
102
103
config_keys () {
103
- regex=" ^([a-zA-Z0-9_\-\/\.]+) *="
104
+ local regex=" ^([a-zA-Z0-9_\-\/\.]+) *="
104
105
105
106
config_init
106
107
107
- keys=()
108
+ local keys=()
109
+ local key
110
+
108
111
while IFS= read -r line || [ -n " $line " ]; do
109
112
if [[ $line =~ $regex ]]; then
110
113
key=" ${BASH_REMATCH[1]} "
You can’t perform that action at this time.
0 commit comments