Hi,

Jonathan Perkin wrote on Tue, May 17, 2011 at 11:02:05PM +0100:

> Add -i to ignore case when matching process name

It seems nobody picked this up, so i had a look at it.

NetBSD has that since March 2005 (committed by sketch@).
FreeBSD copied it from NetBSD a few days later.
procps.cvs.sourceforge.net (used e.g. in Debian) does not have -i.
OpenSolaris does not have -i.

So I'd say we shouldn't add it.

It is not terribly useful; hopefully, you at least know
how the processes you are searching for are called.
Even if not, you can use  ps ax | grep -i  to find out,
then use the exact name you found for pkill.
Personally, i never felt a need for pkill -i,
although i'm using pkill a lot.
It is not universal, so it is likely to degrade interoperability.

Yours,
  Ingo


> Index: pkill.1
> ===================================================================
> RCS file: /cvs/src/usr.bin/pkill/pkill.1,v
> retrieving revision 1.16
> diff -u -r1.16 pkill.1
> --- pkill.1   29 Sep 2010 07:44:56 -0000      1.16
> +++ pkill.1   17 May 2011 21:50:36 -0000
> @@ -36,7 +36,7 @@
>  .Nd find or signal processes by name
>  .Sh SYNOPSIS
>  .Nm pgrep
> -.Op Fl flnovx
> +.Op Fl filnovx
>  .Op Fl d Ar delim
>  .Op Fl G Ar gid
>  .Op Fl g Ar pgrp
> @@ -48,7 +48,7 @@
>  .Op Ar pattern ...
>  .Nm pkill
>  .Op Fl Ar signal
> -.Op Fl fnovx
> +.Op Fl finovx
>  .Op Fl G Ar gid
>  .Op Fl g Ar pgrp
>  .Op Fl P Ar ppid
> @@ -93,6 +93,8 @@
>  or
>  .Nm pkill
>  command.
> +.It Fl i
> +Ignore case when matching process name.
>  .It Fl l
>  Long output.
>  Print the process name in addition to the process ID for each matching
> Index: pkill.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/pkill/pkill.c,v
> retrieving revision 1.19
> diff -u -r1.19 pkill.c
> --- pkill.c   10 Apr 2011 03:20:59 -0000      1.19
> +++ pkill.c   17 May 2011 21:50:36 -0000
> @@ -85,6 +85,7 @@
>  int  longfmt;
>  int  matchargs;
>  int  fullmatch;
> +int  regflags = REG_EXTENDED;
>  kvm_t        *kd;
>  pid_t        mypid;
>  
> @@ -149,7 +150,7 @@
>  
>       criteria = 0;
>  
> -     while ((ch = getopt(argc, argv, "G:P:U:d:fg:lnos:t:u:vx")) != -1)
> +     while ((ch = getopt(argc, argv, "G:P:U:d:fg:ilnos:t:u:vx")) != -1)
>               switch (ch) {
>               case 'G':
>                       makelist(&rgidlist, LT_GROUP, optarg);
> @@ -175,6 +176,9 @@
>                       makelist(&pgrplist, LT_PGRP, optarg);
>                       criteria = 1;
>                       break;
> +             case 'i':
> +                     regflags |= REG_ICASE;
> +                     break;
>               case 'l':
>                       if (!pgrep)
>                               usage();
> @@ -243,7 +247,7 @@
>        * Refine the selection.
>        */
>       for (; *argv != NULL; argv++) {
> -             if ((rv = regcomp(&reg, *argv, REG_EXTENDED)) != 0) {
> +             if ((rv = regcomp(&reg, *argv, regflags)) != 0) {
>                       regerror(rv, &reg, buf, sizeof(buf));
>                       errx(STATUS_BADUSAGE, "bad expression: %s", buf);
>               }
> @@ -419,9 +423,9 @@
>       const char *ustr;
>  
>       if (pgrep)
> -             ustr = "[-flnovx] [-d delim]";
> +             ustr = "[-filnovx] [-d delim]";
>       else
> -             ustr = "[-signal] [-fnovx]";
> +             ustr = "[-signal] [-finovx]";
>  
>       fprintf(stderr, "usage: %s %s [-G gid] [-g pgrp] [-P ppid] [-s sid] "
>           "[-t tty]\n\t[-U uid] [-u euid] [pattern ...]\n", __progname, ustr);

Reply via email to