@@ -20,28 +20,28 @@ core.trap_add() {
2020
2121 # validation
2222 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'
2424 return 1
2525 fi
2626
2727 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'
2929 return 1
3030 fi
3131 for signal_spec in " ${@: 2} " ; do
3232 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'
3434 return 1
3535 fi
3636
3737 local regex=' ^[0-9]+$'
3838 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'
4040 return 1
4141 fi ; unset regex
4242 signal_spec=${signal_spec# SIG}
4343 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"
4545 return 1
4646 fi
4747
@@ -55,7 +55,7 @@ core.trap_add() {
5555 if ! eval " $global_trap_handler_name () {
5656 core.util.trap_handler_common '$signal_spec '
5757 }" ; then
58- printf ' %s\n ' " Error: core.trap_add: Could not eval function"
58+ core.print_error ' Could not eval function'
5959 return 1
6060 fi
6161 # shellcheck disable=SC2064
@@ -80,28 +80,28 @@ core.trap_remove() {
8080
8181 # validation
8282 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'
8484 return 1
8585 fi
8686
8787 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'
8989 return 1
9090 fi
9191 for signal_spec in " ${@: 2} " ; do
9292 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'
9494 return 1
9595 fi
9696
9797 local regex=' ^[0-9]+$'
9898 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'
100100 return 1
101101 fi ; unset regex
102102 signal_spec=" ${signal_spec# SIG} "
103103 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"
105105 return 1
106106 fi
107107
@@ -147,12 +147,12 @@ core.shopt_push() {
147147 local shopt_name=" $2 "
148148
149149 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'
151151 return 1
152152 fi
153153
154154 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'
156156 return 1
157157 fi
158158
@@ -174,7 +174,7 @@ core.shopt_push() {
174174 return $?
175175 fi
176176 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'"
178178 return 1
179179 fi
180180
@@ -197,12 +197,12 @@ core.shopt_pop() {
197197 fi
198198
199199 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'
201201 return 1
202202 fi
203203
204204 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'
206206 return 1
207207 fi
208208
@@ -212,7 +212,7 @@ core.shopt_pop() {
212212
213213 if shopt -u " $shopt_name " ; then : ; else
214214 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 '
216216 return $errcode
217217 fi
218218
@@ -232,12 +232,12 @@ core.err_set() {
232232 ERRCODE=$1
233233 ERR=$2
234234 else
235- printf ' %s\n ' " Error: core.err_set: Incorrect function arguments"
235+ core.print_error ' Incorrect function arguments'
236236 return 1
237237 fi
238238
239239 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"
241241 return 1
242242 fi
243243}
@@ -299,7 +299,7 @@ core.print_stacktrace() {
299299 done ; unset -v i
300300
301301 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"
303303 fi
304304} >&2
305305
@@ -371,7 +371,7 @@ core.get_package_info() {
371371 local toml_file=" $basalt_package_dir /basalt.toml"
372372
373373 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"
375375 fi
376376
377377 local regex=" ^[ \t]*${key_name} [ \t]*=[ \t]*['\" ](.*)['\" ]"
0 commit comments