Skip to content

Commit bb3f8e1

Browse files
committed
fix: Undo deletion of 'core.trap_common_global_handler'
1 parent 009e9fe commit bb3f8e1

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

basalt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = 'Core lightweight functions that any Bash programmer will love'
88

99
[run]
1010
dependencies = ['https://github.com/hyperupcall/bats-all.git@v4.1.0']
11-
sourceDirs = ['pkg/src/public']
11+
sourceDirs = ['pkg/src/public', 'pkg/src/util']
1212
builtinDirs = []
1313
binDirs = []
1414
completionDirs = []

pkg/src/util/util.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# shellcheck shell=bash
2+
3+
core.trap_common_global_handler() {
4+
local signal_spec="$1"
5+
6+
local trap_handlers=
7+
IFS=$'\x1C' read -ra trap_handlers <<< "${___global_trap_table___[$signal_spec]}"
8+
9+
local trap_handler=
10+
for trap_handler in "${trap_handlers[@]}"; do
11+
if [ -z "$trap_handler" ]; then
12+
continue
13+
fi
14+
15+
if declare -f "$trap_handler" &>/dev/null; then
16+
"$trap_handler"
17+
else
18+
printf "%s\n" "Warn: core.trap_add: Function '$trap_handler' registered for signal '$signal_spec' no longer exists. Skipping" >&2
19+
fi
20+
done; unset trap_func
21+
}

0 commit comments

Comments
 (0)