package procps tags 413383 + patch thanks
according to the man page, pgrep should exit with status 2 in case of a syntax error on the command line. Well, it does not: pgrep -y gives a usage message, and exits with status 0. This makes its usage error prone in scripts.
In the file pgrep.c , the function usage(int opt) returns with: exit (opt == '?' ? EXIT_SUCCESS : EXIT_USAGE); Instead, it should exit with: exit (opt == '?' ? EXIT_USAGE : EXIT_SUCCESS); Patch attached.
--- pgrep.c 2007-04-29 23:25:38.000000000 -0700 +++ pgrepFIX.c 2007-04-29 23:27:10.000000000 -0700 @@ -82,7 +82,7 @@ fprintf (stderr, "[-n|-o] [-P PPIDLIST] [-g PGRPLIST] [-s SIDLIST]\n" "\t[-u EUIDLIST] [-U UIDLIST] [-G GIDLIST] [-t TERMLIST] " "[PATTERN]\n"); - exit (opt == '?' ? EXIT_SUCCESS : EXIT_USAGE); + exit (opt == '?' ? EXIT_USAGE : EXIT_SUCCESS); }