diff options
author | William Orr <will@worrbase.com> | 2015-05-10 17:42:09 +1000 |
---|---|---|
committer | Craig Small <csmall@enc.com.au> | 2015-05-10 17:42:09 +1000 |
commit | 9742c74e7c522fe0a08473a9599def465b35a4d0 (patch) | |
tree | 9d5761ab15a3db515aaf91ba126fa0b3b3ff0c48 /pgrep.c | |
parent | 1209e759030cf166d30b94073282d45df0939c0b (diff) | |
download | procps-ng-9742c74e7c522fe0a08473a9599def465b35a4d0.tar.gz |
pgrep: Enable case-insensitive process matching
FreeBSD has case-insensitive matching of processes in pgrep and
pkill, which can be super-useful. This patch uncomments and
documents the code needed to make this work.
Signed-off-by: Craig Small <csmall@enc.com.au>
Diffstat (limited to 'pgrep.c')
-rw-r--r-- | pgrep.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -118,6 +118,7 @@ static int __attribute__ ((__noreturn__)) usage(int opt) fputs(_(" -f, --full use full process name to match\n"), fp); fputs(_(" -g, --pgroup <PGID,...> match listed process group IDs\n"), fp); fputs(_(" -G, --group <GID,...> match real group IDs\n"), fp); + fputs(_(" -i, --ignore-case match case insensitively\n"), fp); fputs(_(" -n, --newest select most recently started\n"), fp); fputs(_(" -o, --oldest select least recently started\n"), fp); fputs(_(" -P, --parent <PPID,...> match only child processes of the given parent\n"), fp); @@ -694,6 +695,7 @@ static void parse_opts (int argc, char **argv) {"full", no_argument, NULL, 'f'}, {"pgroup", required_argument, NULL, 'g'}, {"group", required_argument, NULL, 'G'}, + {"ignore-case", no_argument, NULL, 'i'}, {"newest", no_argument, NULL, 'n'}, {"oldest", no_argument, NULL, 'o'}, {"parent", required_argument, NULL, 'P'}, @@ -727,7 +729,7 @@ static void parse_opts (int argc, char **argv) strcat (opts, "lad:vw"); } - strcat (opts, "LF:cfnoxP:g:s:u:U:G:t:?Vh"); + strcat (opts, "LF:cfinoxP:g:s:u:U:G:t:?Vh"); while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != -1) { switch (opt) { @@ -798,11 +800,11 @@ static void parse_opts (int argc, char **argv) usage ('?'); ++criteria_count; break; -/* case 'i': / * FreeBSD: ignore case. OpenBSD: withdrawn. See -I. This sucks. * / - * if (opt_case) - * usage (opt); - * opt_case = REG_ICASE; - * break; */ + case 'i': /* FreeBSD: ignore case. OpenBSD: withdrawn. See -I. This sucks. */ + if (opt_case) + usage (opt); + opt_case = REG_ICASE; + break; /* case 'j': / * FreeBSD: restricted to the given jail ID * / * break; */ case 'l': /* Solaris: long output format (pgrep only) Should require -f for beyond argv[0] maybe? */ |