1
1
# shellcheck shell=bash
2
2
3
- btoml .quick_string_get () {
4
- unset REPLY; REPLY=
3
+ bash_toml .quick_string_get () {
4
+ unset -v REPLY; REPLY=
5
5
local toml_file=" $1 "
6
6
local key_name=" $2 "
7
7
8
8
if [ ! -f " $toml_file " ]; then
9
- btoml .error " File '$toml_file ' not found"
9
+ bash_toml .error " File '$toml_file ' not found"
10
10
return 1
11
11
fi
12
12
@@ -33,12 +33,12 @@ btoml.quick_string_get() {
33
33
REPLY=" ${BASH_REMATCH[1]} "
34
34
else
35
35
# This should not happen due to the '[[ $line == *"$key_name"*=* ]]' check above
36
- btoml .error " Could not find key '$key_name ' in file '$toml_file '"
36
+ bash_toml .error " Could not find key '$key_name ' in file '$toml_file '"
37
37
return 1
38
38
fi
39
39
}
40
40
41
- btoml .quick_array_get () {
41
+ bash_toml .quick_array_get () {
42
42
unset REPLY; declare -ga REPLY=()
43
43
local toml_file=" $1 "
44
44
local key_name=" $2 "
@@ -47,7 +47,7 @@ btoml.quick_array_get() {
47
47
# ensure.nonzero 'key_name'
48
48
49
49
if [ ! -f " $toml_file " ]; then
50
- btoml .error " File '$toml_file ' does not exist"
50
+ bash_toml .error " File '$toml_file ' does not exist"
51
51
return 2
52
52
fi
53
53
@@ -98,17 +98,21 @@ btoml.quick_array_get() {
98
98
if [[ ${REPLY[$i]} =~ $regex ]]; then
99
99
REPLY[$i ]=" ${BASH_REMATCH[1]} "
100
100
else
101
- btoml .error " Key '$key_name ' in file '$toml_file ' is not valid"
101
+ bash_toml .error " Key '$key_name ' in file '$toml_file ' is not valid"
102
102
return 2
103
103
fi
104
104
done
105
105
else
106
- btoml .error " Key '$key_name ' in file '$toml_file ' must be set to an array that spans one line"
106
+ bash_toml .error " Key '$key_name ' in file '$toml_file ' must be set to an array that spans one line"
107
107
return 2
108
108
fi
109
109
}
110
110
111
- btoml.quick_array_append () {
111
+ bash_toml.quick_string_set () {
112
+ :
113
+ }
114
+
115
+ bash_toml.quick_array_append () {
112
116
local toml_file=" $1 "
113
117
local key_name=" $2 "
114
118
local key_value=" $3 "
@@ -117,15 +121,15 @@ btoml.quick_array_append() {
117
121
# ensure.nonzero 'key_value'
118
122
119
123
if [ ! -f " $toml_file " ]; then
120
- btoml .error " File '$toml_file ' does not exist"
124
+ bash_toml .error " File '$toml_file ' does not exist"
121
125
return 2
122
126
fi
123
127
124
128
if util.get_toml_array " $toml_file " ' dependencies' ; then
125
129
local name=
126
130
for name in " ${REPLY[@]} " ; do
127
131
if [ " ${name%@* } " = " ${key_value%@* } " ]; then
128
- btoml .error " A version of '${name%@* } ' is already installed. Skipping"
132
+ bash_toml .error " A version of '${name%@* } ' is already installed. Skipping"
129
133
return 2
130
134
fi
131
135
done ; unset name
@@ -140,20 +144,20 @@ btoml.quick_array_append() {
140
144
rm " $toml_file .bak"
141
145
fi
142
146
else
143
- btoml .error " Key 'dependencies' not found in file '$toml_file '"
147
+ bash_toml .error " Key 'dependencies' not found in file '$toml_file '"
144
148
return 2
145
149
fi
146
150
}
147
151
148
- btoml .quick_array_remove () {
152
+ bash_toml .quick_array_remove () {
149
153
local toml_file=" $1 "
150
154
local key_value=" $2 "
151
155
152
156
# ensure.nonzero 'toml_file'
153
157
# ensure.nonzero 'key_value'
154
158
155
159
if [ ! -f " $toml_file " ]; then
156
- btoml .error " File '$toml_file ' does not exist"
160
+ bash_toml .error " File '$toml_file ' does not exist"
157
161
return 2
158
162
fi
159
163
@@ -170,7 +174,7 @@ btoml.quick_array_remove() {
170
174
done ; unset -v name
171
175
172
176
if [ " $does_exist " != ' yes' ]; then
173
- btoml .error " The package '$key_value ' is not currently a dependency"
177
+ bash_toml .error " The package '$key_value ' is not currently a dependency"
174
178
return 2
175
179
fi
176
180
@@ -191,7 +195,11 @@ btoml.quick_array_remove() {
191
195
done < " $toml_file .bak" > " $toml_file "
192
196
rm " $toml_file .bak"
193
197
else
194
- btoml .error " Key 'dependencies' not found in file '$toml_file '"
198
+ bash_toml .error " Key 'dependencies' not found in file '$toml_file '"
195
199
return 2
196
200
fi
197
201
}
202
+
203
+ bash_toml.quick_array_replace () {
204
+ :
205
+ }
0 commit comments