diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-06-07 15:25:31 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-06-07 15:25:31 +0000 |
commit | 7e77a481569d15ec7be3c29875af0e859418e800 (patch) | |
tree | cb96328df997ed888960c00f8b2140f6320629b1 /usr.bin | |
parent | 5a8f9cf391e0197f428e5a51085f731dd7d379fd (diff) |
-iname support; karls@inet.no
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/find/extern.h | 3 | ||||
-rw-r--r-- | usr.bin/find/find.1 | 11 | ||||
-rw-r--r-- | usr.bin/find/find.h | 4 | ||||
-rw-r--r-- | usr.bin/find/function.c | 29 | ||||
-rw-r--r-- | usr.bin/find/option.c | 5 |
5 files changed, 44 insertions, 8 deletions
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index ed8e9cca7d0..672563b8d42 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: extern.h,v 1.9 1999/12/04 22:42:31 millert Exp $*/ +/* * $OpenBSD: extern.h,v 1.10 2000/06/07 15:25:30 deraadt Exp $*/ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -63,6 +63,7 @@ PLAN *c_execdir __P((char ***)); PLAN *c_follow __P((void)); PLAN *c_fstype __P((char *)); PLAN *c_group __P((char *)); +PLAN *c_iname __P((char *)); PLAN *c_inum __P((char *)); PLAN *c_links __P((char *)); PLAN *c_ls __P((void)); diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index 4b5b9251c2a..95434a6e68a 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: find.1,v 1.26 2000/03/07 21:11:08 aaron Exp $ +.\" $OpenBSD: find.1,v 1.27 2000/06/07 15:25:30 deraadt Exp $ .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -213,6 +213,11 @@ If is numeric and there is no such group name, then .Ar gname is treated as a group ID. +.It Ic -iname Ar pattern +True if the last component of the pathname being examined +matches +.Ar pattern . +Case insensitive. .It Ic -inum Ar n True if the file has inode number .Ar n . @@ -513,6 +518,7 @@ The options and primaries .Ic -empty , .Ic -follow , .Ic -fstype , +.Ic -iname , .Ic -inum , .Ic -links , .Ic -ls , @@ -524,6 +530,9 @@ and .Ic -print0 are extensions to .St -p1003.2 . +The +.Ic -iname +option was inspired by GNU find. .Pp Historically, the .Fl d , diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h index 314640ca405..778db7014b2 100644 --- a/usr.bin/find/find.h +++ b/usr.bin/find/find.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: find.h,v 1.8 1999/12/04 22:42:31 millert Exp $*/ +/* * $OpenBSD: find.h,v 1.9 2000/06/07 15:25:30 deraadt Exp $*/ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -42,7 +42,7 @@ enum ntype { N_AND = 1, /* must start > 0 */ N_AMIN, N_ANEWER, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CNEWER, N_CTIME, N_DEPTH, N_EMPTY, N_EXEC, N_EXECDIR, - N_EXPR, N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, + N_EXPR, N_FOLLOW, N_FSTYPE, N_GROUP, N_INAME, N_INUM, N_LINKS, N_LS, N_MMIN, N_MAXDEPTH, N_MINDEPTH, N_MTIME, N_NAME, N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH, N_PERM, N_PRINT, N_PRINT0, N_PRUNE, diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 8754de6579a..3713de164ee 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1,4 +1,4 @@ -/* $OpenBSD: function.c,v 1.17 1999/12/04 22:42:32 millert Exp $ */ +/* $OpenBSD: function.c,v 1.18 2000/06/07 15:25:30 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -38,7 +38,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)function.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: function.c,v 1.17 1999/12/04 22:42:32 millert Exp $"; +static char rcsid[] = "$OpenBSD: function.c,v 1.18 2000/06/07 15:25:30 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -910,6 +910,31 @@ c_name(pattern) new->c_data = pattern; return (new); } + +/* + * -iname functions -- + * + * Similar to -name, but does case insensitive matching + * + */ +int +f_iname(plan, entry) + PLAN *plan; + FTSENT *entry; +{ + return (!fnmatch(plan->c_data, entry->fts_name, FNM_CASEFOLD)); +} + +PLAN * +c_iname(pattern) + char *pattern; +{ + PLAN *new; + + new = palloc(N_INAME, f_iname); + new->c_data = pattern; + return (new); +} /* * -newer file functions -- diff --git a/usr.bin/find/option.c b/usr.bin/find/option.c index f535867af1e..4569907a4a5 100644 --- a/usr.bin/find/option.c +++ b/usr.bin/find/option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: option.c,v 1.10 2000/06/07 15:25:00 deraadt Exp $ */ +/* $OpenBSD: option.c,v 1.11 2000/06/07 15:25:30 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -38,7 +38,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)option.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: option.c,v 1.10 2000/06/07 15:25:00 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: option.c,v 1.11 2000/06/07 15:25:30 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -72,6 +72,7 @@ static OPTION options[] = { { "-follow", N_FOLLOW, c_follow, O_ZERO }, { "-fstype", N_FSTYPE, c_fstype, O_ARGV }, { "-group", N_GROUP, c_group, O_ARGV }, + { "-iname", N_INAME, c_iname, O_ARGV }, { "-inum", N_INUM, c_inum, O_ARGV }, { "-links", N_LINKS, c_links, O_ARGV }, { "-ls", N_LS, c_ls, O_ZERO }, |