1
1
# shellcheck shell=bash
2
2
3
- toml .quick_string_get () {
3
+ btoml .quick_string_get () {
4
4
unset REPLY; REPLY=
5
5
local toml_file=" $1 "
6
6
local key_name=" $2 "
7
7
8
8
if [ ! -f " $toml_file " ]; then
9
- bash_toml .error " File '$toml_file ' not found"
9
+ btoml .error " File '$toml_file ' not found"
10
10
return 1
11
11
fi
12
12
@@ -33,12 +33,12 @@ toml.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
- bash_toml .error " Could not find key '$key_name ' in file '$toml_file '"
36
+ btoml .error " Could not find key '$key_name ' in file '$toml_file '"
37
37
return 1
38
38
fi
39
39
}
40
40
41
- toml .quick_array_get () {
41
+ btoml .quick_array_get () {
42
42
unset REPLIES; declare -ga REPLIES=()
43
43
local toml_file=" $1 "
44
44
local key_name=" $2 "
@@ -47,7 +47,7 @@ toml.quick_array_get() {
47
47
# ensure.nonzero 'key_name'
48
48
49
49
if [ ! -f " $toml_file " ]; then
50
- bash_toml .error " File '$toml_file ' does not exist"
50
+ btoml .error " File '$toml_file ' does not exist"
51
51
return 2
52
52
fi
53
53
@@ -98,33 +98,33 @@ toml.quick_array_get() {
98
98
if [[ ${REPLIES[$i]} =~ $regex ]]; then
99
99
REPLIES[$i ]=" ${BASH_REMATCH[1]} "
100
100
else
101
- bash_toml .error " Key '$key_name ' in file '$toml_file ' is not valid"
101
+ btoml .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
- bash_toml .error " Key '$key_name ' in file '$toml_file ' must be set to an array that spans one line"
106
+ btoml .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
- toml .quick_array_append () {
111
+ btoml .quick_array_append () {
112
112
local toml_file=" $1 "
113
113
local key_value=" $2 "
114
114
115
115
# ensure.nonzero 'toml_file'
116
116
# ensure.nonzero 'key_value'
117
117
118
118
if [ ! -f " $toml_file " ]; then
119
- bash_toml .error " File '$toml_file ' does not exist"
119
+ btoml .error " File '$toml_file ' does not exist"
120
120
return 2
121
121
fi
122
122
123
123
if util.get_toml_array " $toml_file " ' dependencies' ; then
124
124
local name=
125
125
for name in " ${REPLIES[@]} " ; do
126
126
if [ " ${name%@* } " = " ${key_value%@* } " ]; then
127
- bash_toml .error " A version of '${name%@* } ' is already installed. Skipping"
127
+ btoml .error " A version of '${name%@* } ' is already installed. Skipping"
128
128
return 2
129
129
fi
130
130
done ; unset name
@@ -139,20 +139,20 @@ toml.quick_array_append() {
139
139
rm " $toml_file .bak"
140
140
fi
141
141
else
142
- bash_toml .error " Key 'dependencies' not found in file '$toml_file '"
142
+ btoml .error " Key 'dependencies' not found in file '$toml_file '"
143
143
return 2
144
144
fi
145
145
}
146
146
147
- toml .quick_array_remove () {
147
+ btoml .quick_array_remove () {
148
148
local toml_file=" $1 "
149
149
local key_value=" $2 "
150
150
151
151
# ensure.nonzero 'toml_file'
152
152
# ensure.nonzero 'key_value'
153
153
154
154
if [ ! -f " $toml_file " ]; then
155
- bash_toml .error " File '$toml_file ' does not exist"
155
+ btoml .error " File '$toml_file ' does not exist"
156
156
return 2
157
157
fi
158
158
@@ -169,7 +169,7 @@ toml.quick_array_remove() {
169
169
done ; unset -v name
170
170
171
171
if [ " $does_exist " != ' yes' ]; then
172
- bash_toml .error " The package '$key_value ' is not currently a dependency"
172
+ btoml .error " The package '$key_value ' is not currently a dependency"
173
173
return 2
174
174
fi
175
175
@@ -190,7 +190,7 @@ toml.quick_array_remove() {
190
190
done < " $toml_file .bak" > " $toml_file "
191
191
rm " $toml_file .bak"
192
192
else
193
- bash_toml .error " Key 'dependencies' not found in file '$toml_file '"
193
+ btoml .error " Key 'dependencies' not found in file '$toml_file '"
194
194
return 2
195
195
fi
196
196
}
0 commit comments