mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
Speed up, fix fish_status_to_signal (#8530)
* Speed up fish_status_to_signal * Use generated kill signals, not hardcoded
This commit is contained in:
parent
ccf0b69c3d
commit
521eebef7b
1 changed files with 5 additions and 8 deletions
|
@ -1,14 +1,11 @@
|
|||
function fish_status_to_signal --description "Print signal name from argument (\$status), or just argument"
|
||||
__fish_make_completion_signals # Make sure signals are cached
|
||||
for arg in $argv
|
||||
if test $arg -gt 128
|
||||
set -l signals SIGHUP SIGINT SIGQUIT SIGILL SIGTRAP SIGABRT SIGBUS \
|
||||
SIGFPE SIGKILL SIGUSR1 SIGSEGV SIGUSR2 SIGPIPE SIGALRM \
|
||||
SIGTERM SIGSTKFLT SIGCHLD SIGCONT SIGSTOP SIGTSTP \
|
||||
SIGTTIN SIGTTOU SIGURG SIGXCPU SIGXFSZ SIGVTALRM \
|
||||
SIGPROF SIGWINCH SIGIO SIGPWR SIGSYS
|
||||
set -l sigix (math $arg - 128)
|
||||
if test $sigix -le (count $signals)
|
||||
echo $signals[$sigix]
|
||||
# Important: each element of $__kill_signals is a string like "10 USR1"
|
||||
if set -l signal_names (string replace -r --filter '^'(math $arg-128)' ' SIG $__kill_signals)
|
||||
# Some signals have multiple mnemonics. Pick the first one.
|
||||
echo $signal_names[1]
|
||||
else
|
||||
echo $arg
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue