From 46d5d44734b09c4566ca8f65b5fb7fabb4e617a0 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 18 Dec 2011 13:39:28 +0100 Subject: [PATCH] pgrep: exit with error message instead of usage() Printing usage() output at error is too noisy. Signed-off-by: Sami Kerola --- pgrep.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/pgrep.c b/pgrep.c index 119c2430..9d8d825e 100644 --- a/pgrep.c +++ b/pgrep.c @@ -732,27 +732,29 @@ static void parse_opts (int argc, char **argv) } } - if(opt_lock && !opt_pidfile){ - warnx(_("-L without -F makes no sense")); - usage(0); - } + if(opt_lock && !opt_pidfile) + errx(EXIT_FAILURE, _("-L without -F makes no sense\n" + "Try `%s --help' for more information."), + program_invocation_short_name); if(opt_pidfile){ opt_pid = read_pidfile(); - if(!opt_pid){ - warnx(_("pidfile not valid")); - usage(0); - } + if(!opt_pid) + errx(EXIT_FAILURE, _("pidfile not valid\n" + "Try `%s --help' for more information."), + program_invocation_short_name); } if (argc - optind == 1) opt_pattern = argv[optind]; else if (argc - optind > 1) - usage (0); - else if (criteria_count == 0) { - warnx(_("no matching criteria specified")); - usage (0); - } + errx(EXIT_FAILURE, _("only one pattern can be provided\n" + "Try `%s --help' for more information."), + program_invocation_short_name); + else if (criteria_count == 0) + errx(EXIT_FAILURE, _("no matching criteria specified\n" + "Try `%s --help' for more information."), + program_invocation_short_name); }