Silence kill completions harder

As we've noticed a few times now, mingw/msys/cygwin has a fairly
horrible kill implementation that annoys us here.

However our workaround wasn't enough - "mingw" is also a name that is
used here and "msys" can also be a substring.

Also we need to silence the `kill` because it's better to not list the
signals than it is to spew errors.

Fixes #8915.
This commit is contained in:
Fabian Homborg 2022-04-26 17:26:10 +02:00
parent 4b99878a42
commit 5b64e3dbe7

View File

@ -8,7 +8,8 @@ function __fish_make_completion_signals --description 'Make list of kill signals
# Just hardcode the signals.
set -l os (uname)
if string match -q 'CYGWIN*' -- $os
or string match -iq Msys -- $os
or string match -eiq Msys -- $os
or string match -eiq mingw -- $os
set -a __kill_signals "1 HUP" "2 INT" "3 QUIT" "4 ILL" "5 TRAP" "6 ABRT" \
"6 IOT" "7 BUS" "8 FPE" "9 KILL" "10 USR1" "11 SEGV" \
"12 USR2" "13 PIPE" "14 ALRM" "15 TERM" "16 STKFLT" "17 CHLD" \
@ -32,13 +33,13 @@ function __fish_make_completion_signals --description 'Make list of kill signals
# Posix systems print out the name of a signal using 'kill -l SIGNUM'.
complete -c kill -s l --description "List names of available signals"
for i in (seq 31)
set -a __kill_signals $i" "(kill -l $i | string upper)
set -a __kill_signals $i" "(kill -l $i 2>/dev/null | string upper)
end
else
# util-linux (on Arch) and procps-ng (on Debian) kill use 'kill -L' to write out a numbered list
# of signals. Use this to complete on both number _and_ on signal name.
complete -c kill -s L --description "List codes and names of available signals"
kill -L | string trim | string replace -ra ' *' \n | while read -l signo signame
kill -L 2>/dev/null | string trim | string replace -ra ' *' \n | while read -l signo signame
set -a __kill_signals "$signo $signame"
end
end