Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: kill builtin argument parsing
- X-seq: zsh-workers 38622
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: kill builtin argument parsing
- Date: Sun, 5 Jun 2016 17:31:57 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=FN8VX+jGXfHKSiCobL6dgTpBAdsNnogaa8kxtn74HQQ=; b=gd4o8TqX/R8W3hn+CGwMm5l+L6eyAYAKixHYBK0jKUzR7Eq+gCUSVEWTF8TVM0dHR3 02yZfsRLxYwEvtrCt+Q9cwSOOo3ckXR3puWgMPBOl7Uhrjhj4V8zjkzzX4dtfZSgUVxK NzKBJZI9jq50mMhX07TR8CUfmMTzDfJkTxy8I3XhQIlhHDT1XihuxKrszLk+7EaoiOXZ EQWm747BL3+Pni1V7yowQWAaFdGEQ/+biOLruyC5WE1SXMT9IbYQ6YXYW1mrTe5beyFK TnTgsR9FN2wuu+oKOFfgVwf4ZmN4cKvat9joWEM3qDxwMpQa8Es1EkzZ3cNI/L8MRRZG BYFA==
- In-reply-to: <e065be41-429a-d39e-2db1-791e97f8f49a@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <e065be41-429a-d39e-2db1-791e97f8f49a@gmail.com>
On Jun 5, 5:35pm, Matthew Malcomson wrote:
}
} The command line I used was:
} kill -1 -- <any pid>
} which ends up killing the current Zsh process.
This is a little odd, because the code that examines argv[1] to see if
it is -l or -s or -n or -<NUM> or -<NAME> also checks whether it is
"--", but then simply discards that. So you can do
kill -- 12345
to send the default signal to process 12345, you just can't precede
the "--" with any of the other options. I suspect this is so that
you can do
kill -- -12345
i.e. force a negative PID in order to kill a process group instead of
having that interpreted as signal number 12345.
Anyway this is clearly incomplete handling of "--". The patch below
means that
kill -- --
will report "not enough arguments" rather than complaining about either
an invalid signal or an invalid PID, but that's probably OK.
diff --git a/Src/jobs.c b/Src/jobs.c
index 2a9dbe7..04cb6b3 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -2527,6 +2527,10 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
argv++;
}
+ /* Discard the standard "-" and "--" option breaks */
+ if (*argv && (*argv)[0] == '-' && (!(*argv)[1] || (*argv)[1] == '-'))
+ argv++;
+
if (!*argv) {
zwarnnam(nam, "not enough arguments");
return 1;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author