diff --git a/NEWS b/NEWS index 1fa44899..59e51319 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ procps-ng-NEXT restore the proper main thread tics valuations issue #280 * free: -L one line output issue #156 * pgrep: Use only --signal option for signal Debian #1031765 + * pgrep: suppress >15 warning if using regex Debian #1037450 * ps: fixed missing or corrupted fields with -m option Debian #1036631, issue #279 * tests: dont compare floats with == issue #271 * top: bad command line arguments yield EXIT_FAILURE issue #273 diff --git a/src/pgrep.c b/src/pgrep.c index 442dbfcc..838bb2d0 100644 --- a/src/pgrep.c +++ b/src/pgrep.c @@ -636,6 +636,27 @@ static size_t get_arg_max(void) return val; } +/* + * Check if we have a long simple (non-regex) match + * Returns true if the string: + * 1) is longer than 15 characters + * 2) Doesn't have | or [ which are used by regex + * This is not an exhaustive list but catches most instances + * It's only used to suppress the warning + */ +static bool is_long_match(const char *str) +{ + int i, len; + + if (str == NULL) + return FALSE; + if (15 >= (len = strlen(str))) + return FALSE; + for (i=0; i 15)) + if ((!matches) && (!opt_full) && is_long_match(opt_pattern)) xwarnx(_("pattern that searches for process name longer than 15 characters will result in zero matches\n" "Try `%s -f' option to match against the complete command line."), program_invocation_short_name);