From 55228758d24331fcf06319f14dfbfc321edf2ba0 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sun, 27 Mar 2005 14:50:10 +0000 Subject: add a -i option to ignore case distinctions in the process match; From: NetBSD; ok millert@ --- usr.bin/pkill/pkill.1 | 8 +++++--- usr.bin/pkill/pkill.c | 16 ++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'usr.bin/pkill') diff --git a/usr.bin/pkill/pkill.1 b/usr.bin/pkill/pkill.1 index 302039ced60..042b1e11cc6 100644 --- a/usr.bin/pkill/pkill.1 +++ b/usr.bin/pkill/pkill.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pkill.1,v 1.3 2004/07/06 14:02:49 jmc Exp $ +.\" $OpenBSD: pkill.1,v 1.4 2005/03/27 14:50:09 robert Exp $ .\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $ .\" .\" Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ .Nd find or signal processes by name .Sh SYNOPSIS .Nm pgrep -.Op Fl flnvx +.Op Fl filnvx .Op Fl G Ar gid .Op Fl P Ar ppid .Op Fl U Ar uid @@ -55,7 +55,7 @@ .Op Ar pattern Op ... .Nm pkill .Op Fl signal -.Op Fl fnvx +.Op Fl finvx .Op Fl G Ar gid .Op Fl P Ar ppid .Op Fl U Ar uid @@ -108,6 +108,8 @@ The value zero is taken to mean the process group ID of the running or .Nm pkill command. +.It Fl i +Ignore case distinctions in both the process table and the supplied pattern. .It Fl l Long output. Print the process name in addition to the process ID for each matching diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c index dc0611ff7b7..ac96a9ca5e2 100644 --- a/usr.bin/pkill/pkill.c +++ b/usr.bin/pkill/pkill.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkill.c,v 1.9 2005/03/02 21:45:53 otto Exp $ */ +/* $OpenBSD: pkill.c,v 1.10 2005/03/27 14:50:09 robert Exp $ */ /* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */ /*- @@ -38,7 +38,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: pkill.c,v 1.9 2005/03/02 21:45:53 otto Exp $"; +static const char rcsid[] = "$OpenBSD: pkill.c,v 1.10 2005/03/27 14:50:09 robert Exp $"; #endif /* !lint */ #include @@ -94,6 +94,7 @@ int inverse; int longfmt; int matchargs; int fullmatch; +int cflags = REG_EXTENDED; kvm_t *kd; pid_t mypid; @@ -158,7 +159,7 @@ main(int argc, char **argv) criteria = 0; - while ((ch = getopt(argc, argv, "G:P:U:d:fg:lns:t:u:vx")) != -1) + while ((ch = getopt(argc, argv, "G:P:U:d:fg:ilns:t:u:vx")) != -1) switch (ch) { case 'G': makelist(&rgidlist, LT_GROUP, optarg); @@ -184,6 +185,9 @@ main(int argc, char **argv) makelist(&pgrplist, LT_PGRP, optarg); criteria = 1; break; + case 'i': + cflags |= REG_ICASE; + break; case 'l': if (!pgrep) usage(); @@ -248,7 +252,7 @@ main(int argc, char **argv) * Refine the selection. */ for (; *argv != NULL; argv++) { - if ((rv = regcomp(®, *argv, REG_EXTENDED)) != 0) { + if ((rv = regcomp(®, *argv, cflags)) != 0) { regerror(rv, ®, buf, sizeof(buf)); errx(STATUS_BADUSAGE, "bad expression: %s", buf); } @@ -415,9 +419,9 @@ usage(void) const char *ustr; if (pgrep) - ustr = "[-flnvx] [-d delim]"; + ustr = "[-filnvx] [-d delim]"; else - ustr = "[-signal] [-fnvx]"; + ustr = "[-signal] [-finvx]"; fprintf(stderr, "usage: %s %s [-G gid] [-P ppid] [-U uid] [-g pgrp] " "[-s sid] [-t tty] [-u euid] pattern ...\n", __progname, ustr); -- cgit v1.2.3