@@ -20,28 +20,28 @@ core.trap_add() {
20
20
21
21
# validation
22
22
if [ -z " $function " ]; then
23
- printf ' %s\n ' " Error: core.trap_add: Function cannot be empty"
23
+ core.print_error ' First argument must not be empty'
24
24
return 1
25
25
fi
26
26
27
27
if (( $# <= 1 )) ; then
28
- printf ' %s\n ' " Error: core.trap_add: Must specify at least one signal"
28
+ core.print_error ' Must specify at least one signal'
29
29
return 1
30
30
fi
31
31
for signal_spec in " ${@: 2} " ; do
32
32
if [ -z " $signal_spec " ]; then
33
- printf ' %s\n ' " Error: core.trap_add: Signal must not be an empty string"
33
+ core.print_error ' Signal must not be an empty string'
34
34
return 1
35
35
fi
36
36
37
37
local regex=' ^[0-9]+$'
38
38
if [[ " $signal_spec " =~ $regex ]]; then
39
- printf ' %s\n ' " Error: core.trap_add: Passing numbers for the signal specs is prohibited"
39
+ core.print_error ' Passing numbers for the signal specs is prohibited'
40
40
return 1
41
41
fi ; unset regex
42
42
signal_spec=${signal_spec# SIG}
43
43
if ! declare -f " $function " & > /dev/null; then
44
- printf ' %s\n ' " Error: core.trap_add: Function '$function ' is not defined" >&2
44
+ core.print_error " Function '$function ' is not defined"
45
45
return 1
46
46
fi
47
47
@@ -55,7 +55,7 @@ core.trap_add() {
55
55
if ! eval " $global_trap_handler_name () {
56
56
core.util.trap_handler_common '$signal_spec '
57
57
}" ; then
58
- printf ' %s\n ' " Error: core.trap_add: Could not eval function"
58
+ core.print_error ' Could not eval function'
59
59
return 1
60
60
fi
61
61
# shellcheck disable=SC2064
@@ -80,28 +80,28 @@ core.trap_remove() {
80
80
81
81
# validation
82
82
if [ -z " $function " ]; then
83
- printf ' %s\n ' " Error: core.trap_remove: Function cannot be empty"
83
+ core.print_error ' First argument must not be empty'
84
84
return 1
85
85
fi
86
86
87
87
if (( $# <= 1 )) ; then
88
- printf ' %s\n ' " Error: core.trap_remove: Must specify at least one signal"
88
+ core.print_error ' Must specify at least one signal'
89
89
return 1
90
90
fi
91
91
for signal_spec in " ${@: 2} " ; do
92
92
if [ -z " $signal_spec " ]; then
93
- printf ' %s\n ' " Error: core.trap_add: Signal must not be an empty string"
93
+ core.print_error ' Signal must not be an empty string'
94
94
return 1
95
95
fi
96
96
97
97
local regex=' ^[0-9]+$'
98
98
if [[ " $signal_spec " =~ $regex ]]; then
99
- printf ' %s\n ' " Error: core.trap_remove: Passing numbers for the signal specs is prohibited"
99
+ core.print_error ' Passing numbers for the signal specs is prohibited'
100
100
return 1
101
101
fi ; unset regex
102
102
signal_spec=" ${signal_spec# SIG} "
103
103
if ! declare -f " $function " & > /dev/null; then
104
- printf ' %s\n ' " Error: core.trap_remove: Function '$function ' is not defined" >&2
104
+ core.print_error " Function '$function ' is not defined"
105
105
return 1
106
106
fi
107
107
@@ -147,12 +147,12 @@ core.shopt_push() {
147
147
local shopt_name=" $2 "
148
148
149
149
if [ -z " $shopt_action " ]; then
150
- printf ' %s\n ' " Error: core.shopt_push: First argument cannot be empty"
150
+ core.print_error ' First argument cannot be empty'
151
151
return 1
152
152
fi
153
153
154
154
if [ -z " $shopt_name " ]; then
155
- printf ' %s\n ' " Error: core.shopt_push: Second argument cannot be empty"
155
+ core.print_error ' Second argument cannot be empty'
156
156
return 1
157
157
fi
158
158
@@ -174,7 +174,7 @@ core.shopt_push() {
174
174
return $?
175
175
fi
176
176
else
177
- printf ' %s\n ' " Error: core.shopt_push: Accepted actions are either '-s' or '-u'" >&2
177
+ core.print_error " Accepted actions are either '-s' or '-u'"
178
178
return 1
179
179
fi
180
180
@@ -197,12 +197,12 @@ core.shopt_pop() {
197
197
fi
198
198
199
199
if (( ${# ___global_shopt_stack___[@]} == 0 )) ; then
200
- printf ' %s\n ' " Error: core.shopt_pop: Unable to pop as nothing is in the shopt stack"
200
+ core.print_error ' Unable to pop as nothing is in the shopt stack'
201
201
return 1
202
202
fi
203
203
204
204
if (( ${# ___global_shopt_stack___[@]} & 1 )) ; then
205
- printf ' %s\n ' " Fatal: core.shopt_pop: Shopt stack is malformed"
205
+ core.print_error ' Shopt stack is malformed'
206
206
return 1
207
207
fi
208
208
@@ -212,7 +212,7 @@ core.shopt_pop() {
212
212
213
213
if shopt -u " $shopt_name " ; then : ; else
214
214
local errcode=$?
215
- printf ' %s\n ' " Fatal: core.shopt_pop: Could not restore previous option " >&2
215
+ core.print_error ' Could not restore previous shopt option '
216
216
return $errcode
217
217
fi
218
218
@@ -232,12 +232,12 @@ core.err_set() {
232
232
ERRCODE=$1
233
233
ERR=$2
234
234
else
235
- printf ' %s\n ' " Error: core.err_set: Incorrect function arguments"
235
+ core.print_error ' Incorrect function arguments'
236
236
return 1
237
237
fi
238
238
239
239
if [ -z " $ERR " ]; then
240
- printf ' %s\n ' " Error: core.err_set: Argument for 'ERR' cannot be empty"
240
+ core.print_error " Argument for 'ERR' cannot be empty"
241
241
return 1
242
242
fi
243
243
}
@@ -299,7 +299,7 @@ core.print_stacktrace() {
299
299
done ; unset -v i
300
300
301
301
if [ " $cd_failed " = ' yes' ]; then
302
- printf ' %s\n ' " Error: core.stacktrace_print: A 'cd' failed, so the stacktrace may include relative paths"
302
+ core.print_error " A 'cd' failed, so the stacktrace may include relative paths"
303
303
fi
304
304
} >&2
305
305
@@ -371,7 +371,7 @@ core.get_package_info() {
371
371
local toml_file=" $basalt_package_dir /basalt.toml"
372
372
373
373
if [ ! -f " $toml_file " ]; then
374
- printf ' %s\n ' " Error: core.get_package_info: File '$toml_file ' could not be found"
374
+ core.print_error " File '$toml_file ' could not be found"
375
375
fi
376
376
377
377
local regex=" ^[ \t]*${key_name} [ \t]*=[ \t]*['\" ](.*)['\" ]"
0 commit comments