History log of /freebsd-10.1-release/usr.bin/find/option.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 247730 03-Mar-2013 dwmalone

Add an option for finding sparse files.

Reviewed by: iedowse
MFC after: 3 weeks


# 238780 25-Jul-2012 jilles

find: Implement real -ignore_readdir_race.

If -ignore_readdir_race is present, [ENOENT] errors caused by deleting a
file after find has read its name from a directory are ignored.

Formerly, -ignore_readdir_race did nothing.

PR: bin/169723
Submitted by: Valery Khromov and Andrey Ignatov


# 222390 27-May-2011 jilles

find: If a part of an expression is unknown, do not call it an option.

Although most of the primaries and operators start with "-", they are not
options.

Examples:
find . -xyz
find . -name xyz -or bad

MFC after: 1 week


# 216370 11-Dec-2010 joel

Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with: imp, rwatson


# 207705 06-May-2010 delphij

Revert r207677 which is considered a violation of style(9).

Pointed out by: bde
Pointy hat to: delphij


# 207677 05-May-2010 delphij

Move SCCS tags to comments as they were already #if 0'ed.


# 200462 13-Dec-2009 delphij

Revert most part of 200420 as requested, as more review and polish is
needed.


# 200420 11-Dec-2009 delphij

Remove unneeded header includes from usr.bin/ except contributed code.

Tested with: make universe


# 176478 23-Feb-2008 imp

Implement a number of primaries present in GNU find, but not present
in our find.

The following are nops because they aren't relevant to our find:
-ignore_readdir_race
-noignore_readdir_race
-noleaf
The following aliaes were created:
-gid -> -group [2]
-uid -> -user [2]
-wholename -> -path
-iwholename -> ipath
-mount -> -xdev
-d -> -depth [1]
The following new primaries were created:
-lname like -name, but matches symbolic links only)
-ilname like -lname but case insensitive
-quit exit(0)
-samefile returns true for hard links to the specified file
-true Always true
I changed one primary to match GNU find since I think our use of it violates
POLA
-false Always false (was an alias for -not!)

Also, document the '+' modifier for -execdir, as well as all of the above.
This was previously implemented.

Document the remaining 7 primaries that are in GNU find, but aren't yet
implemented in find(1)

[1] This was done in GNU find for compatibility with FreeBSD, yet they
mixed up command line args and primary args.

[2] -uid/-gid in GNU find ONLY takes a numeric arg, but that arg does the
normal range thing that. GNU find -user and -uid also take a numberic arg,
but don't do the range processing. find(1) does both for -user and -group,
so making -uid and -gid aliases is compatible for all non-error cases used
in GNU find. While not perfect emulation, this seems a reasonable thing
for us.


# 157555 05-Apr-2006 ceri

Fix options broken when the birthtime related primaries were added.

Note to self: if a comment says a list must be lexically sorted, sort
the list lexically.

Submitted by: Pawel Worach
Approved by: jhb
MFC after: 2 weeks


# 157440 03-Apr-2006 ceri

Add -Btime, -Bnewer, -Bmin, -newerB[Bacmt], -newer[acmt]B options to
work with the st_birthtime field of struct stat.

'B' has been chosen to match the format specifier from stat(1).

Approved by: jhb
MFC after: 2 weeks


# 132814 29-Jul-2004 tjr

Remove partial support for building this on NetBSD.


# 129812 28-May-2004 eik

- introduce a new primary `-depth n', which tests whether
the depth of the current file relative to the starting
point of the traversal is n. The usual +/- modifiers
to the argument apply.

- while I'm here, fix -maxdepth in the case of a depth-first
traversal

Print the top ten maintainers of python module ports
(works with p5-* too):

find /usr/ports -depth 2 \! -name 'py-*' -prune -o \
-depth 3 -name Makefile -execdir make -VMAINTAINER \; \
| sort | uniq -c | sort -nr | head

PR: 66667
Reviewed by: ru, joerg
Approved by: joerg
MFC after: 2 weeks


# 127796 03-Apr-2004 bmilekic

Give find(1) the option -acl to locate files with extended
ACLs. This is similar to what ls(1) can do. It is handy to
have it so that it can be used in conjunction with
"-exec setfacl {} \;" (to find(1)), among others.

This is the submitter's patch, but slightly modified.

PR: bin/65016
Submitted by: Christian S.J. Peron <maneo@bsdpro.com>


# 116333 14-Jun-2003 markm

Fix all WARNS. Checked with "make WARNS=9". Remove unused file.


# 111084 18-Feb-2003 des

Correctly alphabetize options[] so we don't stop at -nouser when searching
for -not.

PR: bin/48423
Submitted by: Matsumura Naoki <matsu@jp.FreeBSD.org>
MFC after: 3 days


# 102083 19-Aug-2002 jmallett

Add a unary -not operator ala -false and !, for sake of completeness.

Obtained from: OpenDarwin
MFC after: 1 week


# 101931 15-Aug-2002 jmallett

Add support for -false instead of '!' cause it can be hard to use that in
some shells, etc., and also for GNU compatability (lack of this broke the
Mono CVS build for me).

MFC after: 1 week


# 93604 01-Apr-2002 obrien

Fix SCM IDs.


# 92786 20-Mar-2002 markm

Remove __P().


# 91400 27-Feb-2002 dwmalone

1) Remove -Wall from Makefile.
2) WARNs fixes (rename option to lookup_option to avoid shadowing, rename
argv to argv1 to avoid shadowing, const stuff, prototypes, __unused).
3) Remove "register"s.


# 76250 03-May-2001 phk

They add the following commands:
-anewer
-cnewer
-mnewer
-okdir
-newer[acm][acmt]

With it, you can form queries like

find . -newerct '1 minute ago' -print

As an extra bonus, the program is ANSI-fied - the original version
relies on some obscure features of K&R C.

(This PR was submitted in 1999, and the submittor has kept the patch
updated ever since, hats off for him guys, and how about you close a PR ??)

PR: 9374
Submitted by: Martin Birgmeier <Martin.Birgmeier@aon.at>


# 72945 23-Feb-2001 knu

Implement the following options and primaries:

-E Interpret regular expressions followed by -regex and -iregex op-
tions as extended (modern) regular expressions rather than basic
regular expressions (BRE's). The re_format(7) manual page fully
describes both formats.

-iname pattern
Like -name, but the match is case insensitive.

-ipath pattern
Like -path, but the match is case insensitive.

-regex pattern
True if the whole path of the file matches pattern using regular
expression. To match a file named ``./foo/xyzzy'', you can use
the regular expression ``.*/[xyz]*'' or ``.*/foo/.*'', but not
``xyzzy'' or ``/foo/''.

-iregex pattern
Like -regex, but the match is case insensitive.

These are meant to be compatible with other find(1) implementations
such as GNU's or NetBSD's except regexp library differences.

Reviewed by: sobomax, dcs, and some other people on -current


# 71422 23-Jan-2001 peter

Add the -empty flag, from OpenBSD. It returns true if the directory
is empty. There doesn't appear to be another easy way to do this.

mobile# mkdir foo
mobile# mkdir foo/bar
mobile# mkdir bar
mobile# find . -empty
./foo/bar
./bar


# 61575 12-Jun-2000 roberto

This patch adds the -mindepth and -maxdepth options to find(1), which
behave as in GNU find (and of course as described in the manual page
diff included). I think these options would be useful for some people.

Some missing $FreeBSD$ tags are also added.

The patch was slightly modified (send-pr mangling of TABS).

PR: bin/18941
Submitted by: Ben Smithurst <ben@scientia.demon.co.uk>


# 54828 19-Dec-1999 roberto

Second part of bin/3648: add -flags to search for specific flags.
I added $FreeBSD$ whicle I was here. The patch wasn't usable anymore
due to its age so I adapted it.

PR: bin/3648
Submitted by: Martin Birgmeier <mbirg@austria.ds.philips.com>


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 32402 10-Jan-1998 jb

A partial frontal lobotomy for find if using the NetBSD libc which
doesn't know about getvfsbyname() and the vfsconf structure. This
disables the -fstype option if compiled with a pre-processor that
defines __NetBSD__. With the FreeBSD built pre-processor, find can only
be built with the FreeBSD libc. So when running with a NetBSD kernel,
FreeBSD's libc will have to return ENOSYS for things that NetBSD
doesn't support. That's life in a hybrid world.


# 31440 28-Nov-1997 steve

Sort option list so that -amin works.

PR: 5171
Submitted by: Dmitrij Tejblum <tejblum@arc.hq.cti.ru>


# 30395 13-Oct-1997 wosch

Add the primaries -mmin, -amin, -cmin to find, similar to the GNU find.


# 28914 29-Aug-1997 imp

Add -execdir which will execute the exec command in the dir of the file
in question. This change and the fts changes should be merged into 2.2-stable
as soon as they are vetted in -current. This should allow cleaning of files
in /tmp to be reneabled.
Obtained from: OpenBSD


# 18681 04-Oct-1996 peter

Implement a -delete option to find. The code is extremely paranoid and
goes to a fair degree of trouble to enable something like this to
be safe: cd /tmp && find . -mtime +7 -delete

It removes both files and directories. It does not attempt to remove
immutable files (an earlier version I showed to a few people did a chflags
and tried to blow away even immutable files. Too risky..)

It is thought to be safe because it forces the fts(3) driven descent to
only do "minimal risk" stuff. specifically, -follow is disabled, it does
checking to see that it chdir'ed to the directory it thought it was
going to, it will *not* pass a pathname with a '/' character in it to
unlink(), so it should be totally immune to symlink tree races. If it runs
into something "fishy", it bails out rather than blunder ahead.. It's better
to do that if somebody is trying to compromise security rather than risk
giving them an opportunity. Since the unlink()/rmdir() is being called
from within the current working directory during the tree descent, there
are no fork/exec overheads or races.

As a side effect of this paranoia, you cannot do a
"find /somewhere/dir -delete", as the last argument to rmdir() is
"/somewhere/dir", and the checking won't allow it. Besides, one would use
rm -rf for that case anyway. :-)

Reviewed by: pst (some time ago, but I've removed the immutable file
deletion code that he complained about since he last saw it)


# 8389 09-May-1995 wollman

Add GNU-style `-print0' primary. This exists so that one can safely
do `find some-nasty-expression -print0 | perl -n0e unlink' and have all
the files actuallly get deleted. (Using `xargs' and `rm' is not safe.)


# 1591 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1590,
which included commits to RCS files with non-trunk default branches.


# 1590 27-May-1994 rgrimes

BSD 4.4 Lite Usr.bin Sources