Skip to content

Commit 588abf2

Browse files
committed
fix: Incorrect error messages and namespace util functions
1 parent e86fc6e commit 588abf2

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

bake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ __bake_main() {
346346

347347
set -ETeo pipefail
348348
shopt -s dotglob extglob globasciiranges globstar lastpipe shift_verbose
349-
export LANG='C' LC_CTYPE='C' LC_NUMERIC='C' LC_TIME='C' LC_COLLATE='C' LC_MONETARY='C' \
350-
LC_MESSAGES='C' LC_PAPER='C' LC_NAME='C' LC_ADDRESS='C' LC_TELEPHONE='C' \
351-
LC_MEASUREMENT='C' LC_IDENTIFICATION='C' LC_ALL='C'
349+
export LANG='C' LC_CTYPE='C' LC_NUMERIC='C' LC_TIME='C' LC_COLLATE='C' \
350+
LC_MONETARY='C' LC_MESSAGES='C' LC_PAPER='C' LC_NAME='C' LC_ADDRESS='C' \
351+
LC_TELEPHONE='C' LC_MEASUREMENT='C' LC_IDENTIFICATION='C' LC_ALL='C'
352352
trap '__bake_trap_err' 'ERR'
353353
bake.cfg pedantic-task-cd 'no'
354354

pkg/src/public/bash-core.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ core.trap_add() {
4444
fi; unset regex
4545
signal_spec=${signal_spec#SIG}
4646
if ! declare -f "$function" &>/dev/null; then
47-
printf '%s\n' "Error: core.trap_add: Function '$function' not defined" >&2
47+
printf '%s\n' "Error: core.trap_add: Function '$function' is not defined" >&2
4848
return 1
4949
fi
5050

@@ -56,7 +56,7 @@ core.trap_add() {
5656
printf -v global_trap_handler_name '%q' "core.trap_handler_${signal_spec}"
5757

5858
if ! eval "$global_trap_handler_name() {
59-
core.trap_handler_common '$signal_spec'
59+
core.util.trap_handler_common '$signal_spec'
6060
}"; then
6161
printf '%s\n' "Error: core.trap_add: Could not eval function"
6262
return 1
@@ -80,21 +80,21 @@ core.trap_remove() {
8080

8181
# validation
8282
if [ -z "$function" ]; then
83-
printf '%s\n' "Error: core.trap_add: First argument cannot be empty"
83+
printf '%s\n' "Error: core.trap_remove: First argument cannot be empty"
8484
return 1
8585
fi
8686
if [ -z "$signal_spec" ]; then
87-
printf '%s\n' "Error: core.trap_add: Second argument cannot be empty"
87+
printf '%s\n' "Error: core.trap_remove: Second argument cannot be empty"
8888
return 1
8989
fi
9090
local regex='^[0-9]+$'
9191
if [[ "$signal_spec" =~ $regex ]]; then
92-
printf '%s\n' "Error: core.trap_add: Passing numbers for the signal specs is prohibited"
92+
printf '%s\n' "Error: core.trap_remove: Passing numbers for the signal specs is prohibited"
9393
return 1
9494
fi; unset regex
9595
signal_spec="${signal_spec#SIG}"
9696
if ! declare -f "$function" &>/dev/null; then
97-
printf '%s\n' "Error: core.trap_add: Function '$function' not defined" >&2
97+
printf '%s\n' "Error: core.trap_remove: Function '$function' is not defined" >&2
9898
return 1
9999
fi
100100

@@ -228,7 +228,7 @@ core.err_set() {
228228
}
229229

230230
# @description Clears any of the global error state (sets to empty string).
231-
# This means any `core.err_exists` calls after this _will_ return `true`
231+
# This means any `core.err_exists` calls after this _will_ `return 1`
232232
# @noargs
233233
# @set number ERRCODE Error code
234234
# @set string ERR Error message

pkg/src/util/util.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# shellcheck shell=bash
22

3-
core.trap_handler_common() {
3+
core.util.trap_handler_common() {
44
local signal_spec="$1"
55

66
local trap_handlers=

tests/trap.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ load './util/init.sh'
1010
run core.trap_add 'nonexistent' 'USR1'
1111

1212
assert_failure
13-
assert_output -p "Function 'nonexistent' not defined"
13+
assert_output -p "Function 'nonexistent' is not defined"
1414
}
1515

1616
@test "Fails when number is given for signal" {

0 commit comments

Comments
 (0)