Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] _pgrep: pkill: fix completion of signals



From: Daniel Hahler <git@xxxxxxxxxx>

This adds the signals after arguments are filtered according to
$optchars.
---
 Completion/Unix/Command/_pgrep | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
index 714bf095b..ec3f8bfd0 100644
--- a/Completion/Unix/Command/_pgrep
+++ b/Completion/Unix/Command/_pgrep
@@ -32,9 +32,7 @@ arguments=('-P[parent process id]:parent process id:->ppid'
      '-x[match exactly]'
      '-z[match only in zones]:zone:_zones')
 
-if [[ $service == 'pkill' ]]; then
-  arguments+=('-'${^signals}'[signal]')
-elif [[ $service == 'pgrep' ]]; then
+if [[ $service == 'pgrep' ]]; then
   arguments+=('-d[output delimiter]:delimiter:compadd ${(s\:\:)IFS}'
         '-l[list name in addition to id]')
 fi
@@ -64,8 +62,12 @@ case "$OSTYPE" in
     optchars="flvxdnoPgsuUGt"
     ;;
 esac
+# Only keep relevant arguments according to $optchars.
 arguments=( ${(M)arguments:#(|\*)(|\(*\))-[$optchars]*}
      '*:process name:->pname')
+if [[ $service == 'pkill' ]]; then
+  arguments+=('-'${^signals}'[signal]')
+fi
 
 _arguments -C -s -w $arguments && ret=0
 
-- 
2.17.0



Messages sorted by: Reverse Date, Date, Thread, Author