]> granicus.if.org Git - procps-ng/commitdiff
pgrep - adds warning that pattern exceeds 15 chars without '-f' option
authorJan Rybar <jrybar@redhat.com>
Tue, 6 Sep 2016 16:41:56 +0000 (18:41 +0200)
committerJan Rybar <jrybar@redhat.com>
Tue, 6 Sep 2016 16:41:56 +0000 (18:41 +0200)
pgrep.c

diff --git a/pgrep.c b/pgrep.c
index 539a2d841b8412045b74f9e3f385a1f33cb1bfbf..c9bc36e8658e469d72704ecda169911105877c2b 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -886,7 +886,14 @@ static void parse_opts (int argc, char **argv)
        }
 
        if (argc - optind == 1)
+       {
                opt_pattern = argv[optind];
+               if ((!opt_full) && (strlen(opt_pattern) > 16))
+                       xwarnx(_("pattern that contains program name longer than 15 characters will result in zero matches\n"
+                                        "Try `%s -f' option for thorough search."),
+                                        program_invocation_short_name);
+       }
+
        else if (argc - optind > 1)
                xerrx(EXIT_USAGE, _("only one pattern can be provided\n"
                                     "Try `%s --help' for more information."),