about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2001-11-06 15:06:59 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2001-11-06 15:06:59 +0000
commitd39feeffc48330e4b16768f881306b75e7673971 (patch)
tree4a950e123288fdfa52283c79c048c2949eed228d
parent42f096be3422e46695798a01c7571bf0515ef1d6 (diff)
downloadzsh-d39feeffc48330e4b16768f881306b75e7673971.tar.gz
zsh-d39feeffc48330e4b16768f881306b75e7673971.tar.xz
zsh-d39feeffc48330e4b16768f881306b75e7673971.zip
16224: add -n option to kill and complete options from _kill
-rw-r--r--ChangeLog7
-rw-r--r--Completion/Unix/Type/_signals17
-rw-r--r--Completion/Zsh/Command/_jobs_builtin2
-rw-r--r--Completion/Zsh/Command/_kill18
-rw-r--r--Doc/Zsh/builtins.yo6
-rw-r--r--Src/jobs.c39
6 files changed, 59 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 45d244e7b..7b09a0325 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-11-06  Oliver Kiddle  <opk@zsh.org>
+
+	* 16224: Src/jobs.c, Doc/Zsh/builtins.yo,
+	Completion/Unix/Type/_signals, Completion/Zsh/Command/_kill,
+	Completion/Zsh/Command/_jobs_builtin: add -n option to kill
+	builtin and use _arguments in _kill to complete options
+
 2001-11-03  Bart Schaefer  <schaefer@zsh.org>
 
 	* 16215: Src/subst.c: save and restore mult_isarr in singsub()
diff --git a/Completion/Unix/Type/_signals b/Completion/Unix/Type/_signals
index 447d9d16c..f882ca9ff 100644
--- a/Completion/Unix/Type/_signals
+++ b/Completion/Unix/Type/_signals
@@ -7,16 +7,15 @@
 #
 # A `-' or `--' as the first argument is ignored.
 
-local expl last=-3 minus
+local expl last minus
 
-while [[ "$1" = -[ap] ]]; do
-  if [[ "$1" = -a ]]; then
-    last=-1
-  else
-    minus=-
-  fi
-  shift
-done
+zparseopts -D -K -E 'p=minus' 'a=last'
+if [[ -z "$last" ]]; then
+  last=-1
+else
+  last=-3
+fi
+[[ -n "$minus" ]] && minus='-'
 
 [[ "$1" = -(|-) ]] && shift
 
diff --git a/Completion/Zsh/Command/_jobs_builtin b/Completion/Zsh/Command/_jobs_builtin
index 39ddb8a45..70804cf0f 100644
--- a/Completion/Zsh/Command/_jobs_builtin
+++ b/Completion/Zsh/Command/_jobs_builtin
@@ -2,7 +2,7 @@
 
 _arguments -C -s \
   "(-d -l -p -r -s *)-Z[specify string to replace shell's argument and environment with]:string" \
-  '(-Z)-d[show directory from which to job was started]' \
+  '(-Z)-d[show directory from which each job was started]' \
   '(-Z)-l[list process IDs]' \
   '(-Z)-p[list process groups]' \
   '(-Z -s)-r[list only running jobs]' \
diff --git a/Completion/Zsh/Command/_kill b/Completion/Zsh/Command/_kill
index 5e3caed6a..8887be5fc 100644
--- a/Completion/Zsh/Command/_kill
+++ b/Completion/Zsh/Command/_kill
@@ -1,6 +1,18 @@
 #compdef kill
 
-_alternative \
-    'signals:: _signals -p' \
+local curcontext="$curcontext" line state ret=1
+
+_arguments -C \
+  '(-s -l 1)-n[specify signal number]:signal number' \
+  '(-n -l 1)-s[specify signal name]:signal:_signals' \
+  '(-n -s)-l[list signal names or numbers of specified signals]:*:signal:_signals' \
+  '(-n -s -l)1::signal:_signals -p' \
+  '*:processes:->processes' && ret=0
+  
+if [[ -n "$state" && -prefix [%0-9]# ]]; then
+  _alternative \
     'processes:: _pids' \
-    'jobs:: _jobs -t'
+    'jobs:: _jobs -t' && ret=0
+fi
+
+return ret
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index ef82f851e..c312842c2 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -534,8 +534,8 @@ used by daemons, to indicate their state.
 findex(kill)
 cindex(killing jobs)
 cindex(jobs, killing)
-xitem(tt(kill) [ tt(-s) var(signal_name) ] var(job) ...)
-xitem(tt(kill) [ tt(-)var(sig) ] var(job) ...)
+xitem(tt(kill) [ tt(-s) var(signal_name) | tt(-n) var(signal_number) | \
+tt(-)var(sig) ] var(job) ...)
 item(tt(kill) tt(-l) [ var(sig) ... ])(
 Sends either tt(SIGTERM) or the specified signal to the given
 jobs or processes.
@@ -544,7 +544,7 @@ 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
 not in the job list.
-In the third form, tt(kill -l), if var(sig) is not
+In the second form, tt(kill -l), if var(sig) is not
 specified the signal names are listed.  Otherwise, for each
 var(sig) that is a name, the corresponding signal number is
 listed.  For each var(sig) that is a signal number or a number
diff --git a/Src/jobs.c b/Src/jobs.c
index f462a0ae8..f3519ae2c 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1500,21 +1500,32 @@ bin_kill(char *nam, char **argv, char *ops, int func)
 		putchar('\n');
 		return 0;
 	    }
-	    if ((*argv)[1] == 's' && (*argv)[2] == '\0')
-		signame = *++argv;
-	    else
-		signame = *argv + 1;
 
-	    /* check for signal matching specified name */
-	    for (sig = 1; sig <= SIGCOUNT; sig++)
-		if (!cstrpcmp(sigs + sig, &signame))
-		    break;
-	    if (*signame == '0' && !signame[1])
-		sig = 0;
-	    if (sig > SIGCOUNT) {
-		zwarnnam(nam, "unknown signal: SIG%s", signame, 0);
-		zwarnnam(nam, "type kill -l for a List of signals", NULL, 0);
-		return 1;
+    	    if ((*argv)[1] == 'n' && (*argv)[2] == '\0') {
+	    	char *endp;
+
+	    	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
+		    signame = *argv + 1;
+
+		/* check for signal matching specified name */
+		for (sig = 1; sig <= SIGCOUNT; sig++)
+		    if (!cstrpcmp(sigs + sig, &signame))
+			break;
+		if (*signame == '0' && !signame[1])
+		    sig = 0;
+		if (sig > SIGCOUNT) {
+		    zwarnnam(nam, "unknown signal: SIG%s", signame, 0);
+		    zwarnnam(nam, "type kill -l for a List of signals", NULL, 0);
+		    return 1;
+		}
 	    }
 	}
 	argv++;