Skip to content

Commit 3b6ab72

Browse files
committed
fix: Do not remove our trap handler too soon
1 parent 617ac72 commit 3b6ab72

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/src/public/bash-core.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,15 @@ core.trap_remove() {
8282

8383
___global_trap_table___["$signal_spec"]="$new_trap_handlers"
8484

85-
# rho (WET)
86-
local global_trap_handler_name=
87-
printf -v global_trap_handler_name '%q' "core.private.trap_handler_${signal_spec}"
88-
89-
unset -f "$global_trap_handler_name"
85+
# If there are no more user-provided trap-handlers (for the particular signal spec in the global trap table),
86+
# then remove our handler from 'trap'
87+
if [ -z "$new_trap_handlers" ]; then
88+
# rho (WET)
89+
local global_trap_handler_name=
90+
printf -v global_trap_handler_name '%q' "core.private.trap_handler_${signal_spec}"
91+
trap -- "$signal_spec"
92+
unset -f "$global_trap_handler_name"
93+
fi
9094
done
9195
}
9296

0 commit comments

Comments
 (0)