commit e4e47a617e6c7cca6141aa34c0cdb47b36746b19
parent c0f540162f56f18cffd5b110557b2af1951f3780
Author: sin <sin@2f30.org>
Date: Tue, 11 Nov 2014 17:11:58 +0000
Handle "--" for -l and -s as well in kill(1)
Diffstat:
M | kill.c | | | 22 | ++++++++++------------ |
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/kill.c b/kill.c
@@ -47,11 +47,9 @@ main(int argc, char *argv[])
if (argc < 2)
usage();
- argc--;
- argv++;
+ argc--, argv++;
if (strcmp(argv[0], "--") == 0) {
- argc--;
- argv++;
+ argc--, argv++;
} else if (argv[0][0] == '-' && isdigit(argv[0][1])) {
/* handle XSI extension -signum */
errno = 0;
@@ -59,11 +57,11 @@ main(int argc, char *argv[])
if (*end != '\0' || errno != 0)
eprintf("%s: bad signal number\n", &argv[0][1]);
sig2name(sig);
- argc--;
- argv++;
+ argc--, argv++;
} else if (strcmp(argv[0], "-l") == 0) {
- argc--;
- argv++;
+ argc--, argv++;
+ if (argc > 0 && strcmp(argv[0], "--") == 0)
+ argc--, argv++;
if (argc == 0) {
for (i = 0; i < LEN(sigs); i++)
puts(sigs[i].name);
@@ -80,8 +78,9 @@ main(int argc, char *argv[])
exit(0);
} else {
if (strcmp(argv[0], "-s") == 0) {
- argc--;
- argv++;
+ argc--, argv++;
+ if (argc > 0 && strcmp(argv[0], "--") == 0)
+ argc--, argv++;
if (argc == 0)
usage();
name = argv[0];
@@ -90,8 +89,7 @@ main(int argc, char *argv[])
name = &argv[0][1];
}
sig = strcmp(name, "0") == 0 ? 0 : name2sig(name);
- argc--;
- argv++;
+ argc--, argv++;
}
if (argc == 0)