[hackers] [sbase] Handle "--" for -l and -s as well in kill(1) || sin
commit e4e47a617e6c7cca6141aa34c0cdb47b36746b19
Author: sin <sin_AT_2f30.org>
Date: Tue Nov 11 17:11:58 2014 +0000
Handle "--" for -l and -s as well in kill(1)
diff --git a/kill.c b/kill.c
index 12751af..e9a643f 100644
--- a/kill.c
+++ b/kill.c
_AT_@ -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;
_AT_@ -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);
_AT_@ -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];
_AT_@ -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)
Received on Tue Nov 11 2014 - 18:13:18 CET
This archive was generated by hypermail 2.3.0
: Tue Nov 11 2014 - 18:24:28 CET