Skip to content

Commit 0867dde

Browse files
committed
Support ZSH when setting trap handlers
1 parent f6e0c63 commit 0867dde

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

pkg/src/util/util.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ core._util.trap_handler_common() {
1919
local code="$2"
2020

2121
local trap_handlers=
22-
IFS=$'\x1C' read -ra trap_handlers <<< "${___global_trap_table___[$signal_spec]}"
22+
if [ -n "$BASH_VERSION" ]; then
23+
IFS=$'\x1C' read -ra trap_handlers <<< "${___global_trap_table___[$signal_spec]}"
24+
elif [ -n "$ZSH_VERSION" ]; then
25+
IFS=$'\x1C' read -rA trap_handlers <<< "${___global_trap_table___[$signal_spec]}"
26+
else
27+
core.panic 'bash-core only supports bash and zsh'
28+
fi
2329

2430
local trap_handler=
2531
for trap_handler in "${trap_handlers[@]}"; do
@@ -75,7 +81,7 @@ core._util.validate_signal() {
7581
# @internal
7682
core._should_print_color() {
7783
local fd="$1"
78-
84+
7985
if [ ${NO_COLOR+x} ]; then
8086
return 1
8187
fi
@@ -95,4 +101,4 @@ core._should_print_color() {
95101
fi
96102

97103
return 1
98-
}
104+
}

0 commit comments

Comments
 (0)