[PATCH 08/10] kill: tell what is wrong rather than output usage()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Getting usage as error message is not specific enough.  As a user I want
to know what is wrong, and if it is unclear after error message how to
recover then I run command with --help.

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 misc-utils/kill.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/misc-utils/kill.c b/misc-utils/kill.c
index 34bd00e..30c209f 100644
--- a/misc-utils/kill.c
+++ b/misc-utils/kill.c
@@ -212,7 +212,7 @@ int main(int argc, char **argv)
 				return EXIT_SUCCESS;
 			}
 			if (2 < argc)
-				usage(stderr);
+				errx(EXIT_FAILURE, _("too many arguments"));
 			/* argc == 2, accept "kill -l $?" */
 			arg = argv[1];
 			if ((ctl.numsig = arg_to_signum(arg, 1)) < 0)
@@ -236,15 +236,15 @@ int main(int argc, char **argv)
 		if (!strcmp(arg, "-p") || !strcmp(arg, "--pid")) {
 			ctl.do_pid = 1;
 			if (ctl.do_kill)
-				usage(stderr);
+				errx(EXIT_FAILURE, _("%s and %s are mutually exclusive"), "--pid", "--signal");
 			continue;
 		}
 		if (!strcmp(arg, "-s") || !strcmp(arg, "--signal")) {
 			if (argc < 2)
-				usage(stderr);
+				errx(EXIT_FAILURE, _("not enough arguments"));
 			ctl.do_kill = 1;
 			if (ctl.do_pid)
-				usage(stderr);
+				errx(EXIT_FAILURE, _("%s and %s are mutually exclusive"), "--pid", "--signal");
 			argc--, argv++;
 			arg = *argv;
 			if ((ctl.numsig = arg_to_signum(arg, 0)) < 0) {
@@ -255,7 +255,7 @@ int main(int argc, char **argv)
 		}
 		if (!strcmp(arg, "-q") || !strcmp(arg, "--queue")) {
 			if (argc < 2)
-				usage(stderr);
+				errx(EXIT_FAILURE, _("option '%s' requires an argument"), arg);
 			argc--, argv++;
 			arg = *argv;
 #ifdef HAVE_SIGQUEUE
@@ -277,14 +277,14 @@ int main(int argc, char **argv)
 			break;
 		arg++;
 		if ((ctl.numsig = arg_to_signum(arg, 0)) < 0)
-			usage(stderr);
+			errx(EXIT_FAILURE, _("invalid sigval argument"));
 		ctl.do_kill = 1;
 		if (ctl.do_pid)
-			usage(stderr);
+			errx(EXIT_FAILURE, _("%s and %s are mutually exclusive"), "--pid", "--signal");
 		continue;
 	}
 	if (!*argv)
-		usage(stderr);
+		errx(EXIT_FAILURE, _("not enough arguments"));
 	if (ctl.do_pid)
 		ctl.numsig = -1;
 
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux