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

Re: kill builtin



Oliver Kiddle wrote:

> ...
> 
> > _kill or _signals problem (for me):
> > 
> > % kill -SIG<TAB>
> > --> completing corrections
> > -IO    -SEGV  -SYS   -URG
> > --> completing original
> > -SIG
> > % kill -IOEGV
> 
> I get a similar problem (-SEGVEGV). I can't see anything wrong with
> _signals so it seems to me to be _approximate/_correct.

Right, I've prepared a fix for that. The compadd function in
_approximate was seeing -SEGV and thought that was a group name option
to compadd, not looking at the `-' argument before it.

I also had prepared a fix for the other things you fixed, so I only
add the stuff I have which you haven't done.

The patch changes _signals to accept a -s option meaning that
SIG-prefixes are to be understood (since they probably aren't allowed
everywhere). It also removes the test in _kill (testing for -prefix [%0-9]#).
I know what that was supposed to do, but it made completion of pids by
command names fail, obviously. And finally, there is a bit of
documentation for the optional SIG prefix.

Bye
  Sven

Index: Completion/Base/Completer/_approximate
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_approximate,v
retrieving revision 1.6
diff -u -r1.6 _approximate
--- Completion/Base/Completer/_approximate	2001/08/20 13:13:50	1.6
+++ Completion/Base/Completer/_approximate	2002/01/07 13:17:37
@@ -60,8 +60,8 @@
       PREFIX="(#a${_comp_correct})$PREFIX"
     fi
 
-    (( $_correct_group && $argv[(I)-*[JV]] )) &&
-        _correct_expl[_correct_group]=${argv[(R)-*[JV]]}
+    (( $_correct_group && ${${argv[1,(r)-(|-)]}[(I)-*[JV]]} )) &&
+        _correct_expl[_correct_group]=${argv[1,(r)-(-|)][(R)-*[JV]]}
 
     builtin compadd "$_correct_expl[@]" "$@"
   }
Index: Completion/Unix/Type/_signals
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_signals,v
retrieving revision 1.3
diff -u -r1.3 _signals
--- Completion/Unix/Type/_signals	2001/12/21 16:33:39	1.3
+++ Completion/Unix/Type/_signals	2002/01/07 13:17:37
@@ -4,12 +4,13 @@
 #
 # -a  use all signals (even the pseudo-signals)
 # -p  needs a `-' prefix
+# -s  SIG prefix allowed
 #
 # A `-' or `--' as the first argument is ignored.
 
-local expl last minus
+local expl last minus pre sigs
 
-zparseopts -D -K -E 'p=minus' 'a=last'
+zparseopts -D -K -E 'p=minus' 'a=last' 's=pre'
 if [[ -z "$last" ]]; then
   last=-1
 else
@@ -24,14 +25,21 @@
    [[ -prefix -* ]]; then
   local disp tmp
 
-  [[ -prefix ${minus}SIG* ]] && minus+=SIG
   if zstyle -t ":completion:${curcontext}:signals" prefix-hidden; then
     tmp=( "${(@)signals[1,last]}" )
     disp=(-d tmp)
   else
     disp=()
   fi
+
+  if [[ -n "$pre" && $PREFIX = ${minus}S* ]]; then
+    sigs=( "${minus}SIG${(@)^signals[1,last]}" )
+    (( $#disp )) && tmp=( "$tmp[@]" "${(@)signals[1,last]}" )
+  else
+    sigs=()
+  fi
+
   _wanted signals expl signal \
       compadd "$@" "$disp[@]" -M 'm:{a-z}={A-Z}' - \
-              "${minus}${(@)^signals[1,last]}"
+              "${minus}${(@)^signals[1,last]}" "$sigs[@]"
 fi
Index: Completion/Zsh/Command/_kill
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_kill,v
retrieving revision 1.2
diff -u -r1.2 _kill
--- Completion/Zsh/Command/_kill	2001/11/06 15:07:00	1.2
+++ Completion/Zsh/Command/_kill	2002/01/07 13:17:37
@@ -4,12 +4,12 @@
 
 _arguments -C \
   '(-s -l 1)-n[specify signal number]:signal number' \
-  '(-n -l 1)-s[specify signal name]:signal:_signals' \
+  '(-n -l 1)-s[specify signal name]:signal:_signals -s' \
   '(-n -s)-l[list signal names or numbers of specified signals]:*:signal:_signals' \
-  '(-n -s -l)1::signal:_signals -p' \
+  '(-n -s -l)1::signal:_signals -p -s' \
   '*:processes:->processes' && ret=0
   
-if [[ -n "$state" && -prefix [%0-9]# ]]; then
+if [[ -n "$state" ]]; then
   _alternative \
     'processes:: _pids' \
     'jobs:: _jobs -t' && ret=0
Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.42
diff -u -r1.42 builtins.yo
--- Doc/Zsh/builtins.yo	2001/11/09 16:47:45	1.42
+++ Doc/Zsh/builtins.yo	2002/01/07 13:17:38
@@ -539,7 +539,8 @@
 item(tt(kill) tt(-l) [ var(sig) ... ])(
 Sends either tt(SIGTERM) or the specified signal to the given
 jobs or processes.
-Signals are given by number or by names, without the `tt(SIG)' prefix.
+Signals are given by number or by names, with or without the `tt(SIG)'
+prefix.
 If the signal being sent is not `tt(KILL)' or `tt(CONT)', then the job
 will be sent a `tt(CONT)' signal if it is stopped.
 The argument var(job) can be the process ID of a job

-- 
Sven Wischnowsky                           wischnow@xxxxxxxxx



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