]> granicus.if.org Git - procps-ng/commitdiff
pgrep: exit with error message instead of usage()
authorSami Kerola <kerolasa@iki.fi>
Sun, 18 Dec 2011 12:39:28 +0000 (13:39 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 20 Dec 2011 16:30:54 +0000 (17:30 +0100)
Printing usage() output at error is too noisy.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
pgrep.c

diff --git a/pgrep.c b/pgrep.c
index 119c243035cb05a8c1846c361858021a0fc0cd89..9d8d825e7b2c472b590187600bf3b81343f8a33a 100644 (file)
--- 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);
 }