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

Re: kill builtin



Gerald Britton wrote:
> 
> Discovered today that redhat's initscripts try to execute roughly:
> 
>         $SHELL -c kill -SIGIO $PID
> 
> which works if root's shell is bash, the util-linux kill command also
> accepts -SIG<SIG> args, however, zsh's kill builtin doesn't accept this.
> it seems like a perfectly simple patch to do, and i'd probably do it myself
> if it weren't for being behind a 14.4 cellular link at the moment (it was the
> ppp-watch stuff in redhat's initscripts which tried to do that ;)

Thanks for reporting this. The patch below adds that. We should
probably do the same for trap.

I seem to remember that strncasecmp isn't portable and we've not used
it elsewhere so I've used an uppercase conversion followed by strncmp.
As a result, it no longer uses a strcoll based comparison for finding
the signals. Anyone know if that was necessary (seemed a bit weird to
me)? For the trap builtin, strncasecmp would again be useful so it
might be better just to implement one.

Geoff Wing wrote:
> 
> kill problem:
> 
> % kill -n
> <coredump>  Missing a check for the argument:

kill -s suffers the same problem so 4.0 also needs fixing. The easiest
might be if I just apply this and 16224 to 4.0 but if anyone objects I
can instead fix kill -s in 4.0.

I've also got it to print an error if no pids are specified.

> _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.

Anyway, I'm now away till January. Have a good Christmas everyone.

Oliver

Index: Completion/Unix/Type/_signals
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_signals,v
retrieving revision 1.2
diff -u -r1.2 _signals
--- Completion/Unix/Type/_signals	2001/11/06 15:07:00	1.2
+++ Completion/Unix/Type/_signals	2001/12/21 15:48:24
@@ -21,9 +21,10 @@
 
 if [[ -z "$minus" ]] ||
    ! zstyle -T ":completion:${curcontext}:signals" prefix-needed ||
-   [[ "$PREFIX" = -* ]]; then
+   [[ -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)
Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.14
diff -u -r1.14 jobs.c
--- Src/jobs.c	2001/11/06 15:07:00	1.14
+++ Src/jobs.c	2001/12/21 15:48:25
@@ -1504,20 +1504,29 @@
     	    if ((*argv)[1] == 'n' && (*argv)[2] == '\0') {
 	    	char *endp;
 
-	    	sig = zstrtol(*++argv, &endp, 10);
+	    	if (!*++argv) {
+		    zwarnnam(nam, "-n: argument expected", NULL, 0);
+		    return 1;
+		}
+		sig = zstrtol(*argv, &endp, 10);
 		if (*endp) {
 		    zwarnnam(nam, "invalid signal number", signame, 0);
 		    return 1;
 		}
 	    } else {
-		if ((*argv)[1] == 's' && (*argv)[2] == '\0')
-		    signame = *++argv;
-		else
+		if (!((*argv)[1] == 's' && (*argv)[2] == '\0'))
 		    signame = *argv + 1;
+		else if (!(*++argv)) {
+		    zwarnnam(nam, "-s: argument expected", NULL, 0);
+		    return 1;
+		} else
+		    signame = *argv;
+		makeuppercase(&signame);
+		if (!strncmp(signame, "SIG", 3)) signame+=3;
 
 		/* check for signal matching specified name */
 		for (sig = 1; sig <= SIGCOUNT; sig++)
-		    if (!cstrpcmp(sigs + sig, &signame))
+		    if (!strcmp(*(sigs + sig), signame))
 			break;
 		if (*signame == '0' && !signame[1])
 		    sig = 0;
@@ -1529,6 +1538,11 @@
 	    }
 	}
 	argv++;
+    }
+
+    if (!*argv) {
+    	zwarnnam(nam, "not enough arguments", NULL, 0);
+	return 1;
     }
 
     queue_signals();

_____________________________________________________________________
This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp



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