From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: kill builtin argument parsing
Date: Sun, 5 Jun 2016 17:31:57 -0700 [thread overview]
Message-ID: <160605173157.ZM9449@torch.brasslantern.com> (raw)
In-Reply-To: <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;
prev parent reply other threads:[~2016-06-06 0:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-05 16:35 Matthew Malcomson
2016-06-06 0:31 ` Bart Schaefer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=160605173157.ZM9449@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).