From a71bb03f23d1740bfe6d356347bdddac07c9bd1c Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Mon, 22 May 2017 20:17:08 -0700 Subject: [PATCH] fix `killall` completions This fixes the obvious error in handling the `-u` short flag. See issue #4052. --- share/completions/killall.fish | 86 +++++++++++++++++----------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/share/completions/killall.fish b/share/completions/killall.fish index daf661796..b94fa2b03 100644 --- a/share/completions/killall.fish +++ b/share/completions/killall.fish @@ -1,44 +1,46 @@ -# For Solaris, `killall` kills all processes, so we really don't want to invoke it. +# On Solaris, `killall` kills all processes. So we don't want to bother providing completion +# support on that OS. set -l OS (uname) -if test "$OS" != 'SunOS' - __fish_make_completion_signals - - for i in $__kill_signals - set -l numname (string split " " -- $i) - set -l number $numname[1] - set -q numname[2] - and set -l name $numname[2] - complete -c killall -o $number -d $name - complete -c killall -o $name - # Doesn't work in OS X; -s is simulate - test "$OS" != 'Darwin' - and complete -c killall -s s -x -a "$number $name" - end - - complete -c killall -xa '(__fish_complete_proc)' - - if killall --version >/dev/null ^/dev/null # GNU - complete -c killall -s e -l exact -d 'Require an exact match for very long names' - complete -c killall -s I -l ignore-case -d 'Do case insensitive process name match' - complete -c killall -s g -l process-group -d 'Kill the process group to which the process belongs. The kill signal is only sent once per group, even if multiple processes belonging to the same process group were found' - complete -c killall -s i -l interactive -d 'Interactively ask for confirmation before killing' - complete -c killall -s u -l user -d 'Kill only processes the specified user owns. Command names are optional' -x - complete -c killall -s -u -l user -x -a "(__fish_complete_users)" - complete -c killall -s w -l wait -d 'Wait for all killed processes to die. killall checks once per second if any of the killed processes still exist and only returns if none are left. Note that killall may wait forever if the signal was ignored, had no effect, or if the process stays in zombie state' - complete -c killall -s v -l version -d 'Print version' - else - complete -c killall -s v -d 'Be more verbose about what will be done' - complete -c killall -s e -d 'Use effective user ID instead of the real user ID for matching processes specified with the -u option' - complete -c killall -s help -d 'Print help and exit' - complete -c killall -s l -d 'List names of available signals and exit' - complete -c killall -s m -d 'Case sensitive argument match for processed' - complete -c killall -s s -d 'Simulate, but do not send any signals' - complete -c killall -s d -d "Print detailed info. Doesn't send signals" - complete -c killall -s u -x -d 'Only processes for USER' - complete -c killall -s -u -l user -x -a "(__fish_complete_users)" - complete -c killall -s t -d 'Limit to processes running on specified TTY' - complete -c killall -s t -xa "(ps a -o tty | sed 1d | uniq)" - complete -c killall -s c -x -d 'Limit to processes matching specified PROCNAME' - complete -c killall -s z -d 'Do not skip zombies' - end +if test "$OS" = 'SunOS' + exit 0 +end + +__fish_make_completion_signals + +for i in $__kill_signals + set -l numname (string split " " -- $i) + set -l number $numname[1] + set -q numname[2] + and set -l name $numname[2] + complete -c killall -o $number -d $name + complete -c killall -o $name + # The `-s` flag doesn't work in OS X + test "$OS" != 'Darwin' + and complete -c killall -s s -x -a "$number $name" +end + +complete -c killall -xa '(__fish_complete_proc)' + +if killall --version >/dev/null ^/dev/null # GNU + complete -c killall -s e -l exact -d 'Require an exact match for very long names' + complete -c killall -s I -l ignore-case -d 'Do case insensitive process name match' + complete -c killall -s g -l process-group -d 'Kill the process group to which the process belongs. The kill signal is only sent once per group, even if multiple processes belonging to the same process group were found' + complete -c killall -s i -l interactive -d 'Interactively ask for confirmation before killing' + complete -c killall -s u -l user -x -a "(__fish_complete_users)" -d 'Kill only processes the specified user owns. Command names are optional' + complete -c killall -s w -l wait -d 'Wait for all killed processes to die' + complete -c killall -s v -l version -d 'Print version' +else # probably BSD + complete -c killall -s v -d 'Be more verbose about what will be done' + complete -c killall -s e -d 'Use effective UID instead of the real UID for matching processes specified with the -u option' + complete -c killall -s help -d 'Print help and exit' + complete -c killall -s l -d 'List names of available signals and exit' + complete -c killall -s m -d 'Case sensitive argument match for processed' + complete -c killall -s s -d 'Simulate, but do not send any signals' + complete -c killall -s d -d "Print detailed info. Doesn't send signals" + complete -c killall -s u -x -a "(__fish_complete_users)" -d 'Kill only processes the specified user owns. Command names are optional' + complete -c killall -s -u -l user -x -a "(__fish_complete_users)" + complete -c killall -s t -d 'Limit to processes running on specified TTY' + complete -c killall -s t -xa "(ps a -o tty | sed 1d | uniq)" + complete -c killall -s c -x -d 'Limit to processes matching specified PROCNAME' + complete -c killall -s z -d 'Do not skip zombies' end