about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2001-12-21 16:33:39 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2001-12-21 16:33:39 +0000
commit1b608e1b9af7a86c7c26c5f8aea27602af3077ea (patch)
tree1258c01138b360a911cbae72f8065dc2ede2cd15 /Src
parent1d6f9fc0f03422007adc7fd23328d53691b9513f (diff)
downloadzsh-1b608e1b9af7a86c7c26c5f8aea27602af3077ea.tar.gz
zsh-1b608e1b9af7a86c7c26c5f8aea27602af3077ea.tar.xz
zsh-1b608e1b9af7a86c7c26c5f8aea27602af3077ea.zip
16372: allow signal names to be prefixed by `SIG' with kill builtin and fix
problem with no argument to kill -n and -s options
Diffstat (limited to 'Src')
-rw-r--r--Src/jobs.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/Src/jobs.c b/Src/jobs.c
index f3519ae2c..fc3737fa9 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1504,20 +1504,29 @@ bin_kill(char *nam, char **argv, char *ops, int func)
     	    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;
@@ -1531,6 +1540,11 @@ bin_kill(char *nam, char **argv, char *ops, int func)
 	argv++;
     }
 
+    if (!*argv) {
+    	zwarnnam(nam, "not enough arguments", NULL, 0);
+	return 1;
+    }
+
     queue_signals();
     setcurjob();