Home | History | Annotate | only in /src/usr.bin/find
History log of /src/usr.bin/find
RevisionDateAuthorComments
 1.15 03-Aug-2023  rin Revert CC_WNO_USE_AFTER_FREE from Makefile's (thanks uwe@)
 1.14 03-Aug-2023  rin Sprinkle CC_WNO_USE_AFTER_FREE for GCC 12

All of them are blamed for idiom equivalent to:
newbuf = realloc(buf, size);
p = newbuf + (p - buf);
 1.13 14-Apr-2009  lukem Enable WARNS=4 by default for usr.bin, except for:
awk bdes checknr compile_et error gss hxtool kgetcred kinit
klist ldd less lex locale login m4 man menuc mk_cmds
mklocale msgc openssl rpcgen rpcinfo sdiff spell ssh
string2key telnet tn3270 verify_krb5_conf xlint
 1.12 14-Dec-2006  he branches: 1.12.20;
Adapt find to the move of string_to_flags() and flags_to_string() to
libutil.
 1.11 11-Oct-2006  apb De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.10 26-Aug-2006  christos More programs using efun.
 1.9 18-Sep-2002  lukem makefile delint. use NETBSDSRCDIR as appropriate
 1.8 03-Jan-1999  lukem Add support for "-flags [-]flags", which matches the file flags in a
similar way that "-perm [-]mode" matches the file mode.
 1.7 21-Feb-1998  christos Simplify the function calling code and warnsify.
 1.6 02-Feb-1998  mrg merge lite2, sans getvfsbyname in functions.c (waiting on libc)
 1.5 19-Oct-1997  lukem disable WARNS for now
 1.4 09-Jan-1997  tls RCS ID police
 1.3 28-Jan-1994  cgd don't need -lutil
 1.2 31-Jul-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.12.20.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.30 22-Jan-2022  christos Use /dev/tty for SIGINFO
Fix some size_t<->int
 1.29 13-Jun-2016  pgoyette Add new primaries -asince, -csince, and -since to compare file's
attributes against a user-specified timestamp (rather than the
attributes of a reference file).

Update the parse routines so they have access to the name of the
option being parsed. This enables accurate error reporting for
"aliases" of primaries.

Now that aliases work, introduce some aliases for consistency with
Gnu findutils.
 1.28 19-Jul-2007  daniel branches: 1.28.16;
Add the '-E' option to interpret regexes as extended regexes. While we
are here, fix ordering in usage information by putting '-X' in the proper
place.

Addition of '-E' was discussed on tech-userlevel.
 1.27 06-Feb-2007  elad Add -delete from FreeBSD.
 1.26 11-Oct-2006  apb De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.25 07-Oct-2006  apb Add support for "find ... -exec ... {} +".

The code is from John Hawkinson in PR 20470. I adapted it to current,
and made some KNF and comment changes.
 1.24 26-Aug-2006  christos More programs using efun.
 1.23 20-Feb-2006  jschauma Add a new primary '-exit n':
This primary causes find to stop traversing the filesystem and
exit immediately if a previous condition was met. If no value is
specified, the exit value will be 0, else n. Note that other
primaries will be evaluated and acted upon before exiting.

Ok matt@, garbled@.
 1.22 09-Nov-2005  reed Add -false switch. From man page:

-false This primary always evaluates to false. This can be used follow-
ing a primary that caused the expression to be true to make the
expression to be false. This can be useful after using a -fprint
primary so it can continue to the next expression (using an -or
operator, for example).

This was brought up on the tech-userlevel list in October.

Using -fprint on findutils or new NetBSD find(1) does not do what
I wanted. For example, if saving results of all files that start
with a vowel or saving results of all files owned by group operator,
then the list of files owned by group operator would not include
the files starting with a vowel.

findutils's find has a workaround for this with -false and also a
"," comma opeator. (I made add this comma operator later; you can use
the comma to perform multiple independent tests.)
 1.21 12-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

Note that this example will NOT include entry in file2 if it is
matched in first expression. (This also is same behaviour as
findutils, and I have implemented a -false primary to handle that.
I will commit it later.)

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.

This was discussed on tech-userlevel.
 1.20 07-Aug-2003  agc branches: 1.20.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.19 03-Aug-2003  provos Implement -iname for case insensitive matching on file names.
From freebsd/openbsd. Approved by jaromir@, manu@, perry@.
 1.18 23-Feb-2003  jhawk eleminate forward decl of 'struct stat'
 1.17 27-Sep-2002  provos support for -empty, -execdir, -mindepth, -maxdepth to match other UNIX-like
systems. based on work by tholo@openbsd.org. approved by perry.
 1.16 02-Dec-2001  kleink Since we've already been down that road with -cnewer, support GNU find(1)'s
-anewer as well.
 1.15 01-Dec-2001  kleink Add a "cnewer" primary which evaluates true if a file has a more recent
ctime than its argument.

From kre in PR bin/14802; originally suggested name was "updated" but
renamed due to GNU find(1) being prior art for this functionality.
 1.14 21-Sep-2001  enami Reallocate memory correctly while substituting the braces.
 1.13 10-Mar-2000  itohy Add -s (sort) option, which causes entries in each directory sorted.
Similar to FreeBSD's.
 1.12 20-Jul-1999  cgd add -regex and -iregex primaries which, like GNU find's primaries of the
same name, match files' entire paths against regular expressions.
-regex is case sensitive, -iregex is case-insensitive. Note that these
primaries are _not_ entirely compatible with the GNU find primaries,
because their BREs appear to support alternation with \| whereas our BREs
do not. Also note there are no primaries which provide extended regular
expressions matching, though if they are desired they would be trivial
to implement.
 1.11 16-Jan-1999  simonb branches: 1.11.2;
Add GNU-style -{a,c,m}min primaries.
 1.10 12-Jan-1999  lukem Add support for -printx, which quotes pathnames in an xargs friendly way.
From [bin/6790] by Eric Fischer <eric@fudge.uchicago.edu>
 1.9 03-Jan-1999  lukem Add support for "-flags [-]flags", which matches the file flags in a
similar way that "-perm [-]mode" matches the file mode.
 1.8 21-Feb-1998  christos Simplify the function calling code and warnsify.
 1.7 02-Feb-1998  mrg merge lite2, sans getvfsbyname in functions.c (waiting on libc)
 1.6 19-Oct-1997  lukem fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix)
 1.5 09-Jan-1997  tls RCS ID police
 1.4 30-Dec-1993  jtc Merged our bugfixes with the 4.4BSD find from uunet.
 1.3 27-Oct-1993  jtc Added -print0 (like GNU find). This will allow file names that contain
newlines to be correctly interpreted by programs that process find
output.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.2.1 20-Aug-1999  cgd pull up rev 1.12 from trunk. (cgd)
 1.20.4.2 11-Oct-2005  reed Revert changes. I accidently committed to netbsd-2.
 1.20.4.1 11-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

This was discussed on tech-userlevel.

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.
 1.28.16.2 19-Jul-2007  daniel Add the '-E' option to interpret regexes as extended regexes. While we
are here, fix ordering in usage information by putting '-X' in the proper
place.

Addition of '-E' was discussed on tech-userlevel.
 1.28.16.1 19-Jul-2007  daniel file extern.h was added on branch matt-mips64 on 2007-07-19 07:49:31 +0000
 1.93 02-Nov-2020  uwe Use \*q to refer to ascii quote to save fontlock from confusion.
 1.92 01-Nov-2020  kim Bump date (for "-not")
 1.91 01-Nov-2020  wiz Properly quote '\;' in example.
 1.90 01-Nov-2020  kim Document the -not operator
 1.89 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.88 04-Jun-2017  abhinav Fix typo: s/compatability/compatibility/
 1.87 13-Jun-2016  wiz Remove trailing whitespace. Remove unnecessary quotes.
 1.86 13-Jun-2016  pgoyette Add new primaries -asince, -csince, and -since to compare file's
attributes against a user-specified timestamp (rather than the
attributes of a reference file).

Update the parse routines so they have access to the name of the
option being parsed. This enables accurate error reporting for
"aliases" of primaries.

Now that aliases work, introduce some aliases for consistency with
Gnu findutils.
 1.85 12-Jun-2016  pgoyette Use .Ic markup for consistency with the rest of the document
 1.84 12-Jun-2016  pgoyette Further clarification of the treatment of numeric user and group names.
 1.83 12-Jun-2016  dholland Extend the numeric handling for uids with -user to gids with -group, and
document it. Leftover bit of PR 46158.
 1.82 12-Jun-2016  pgoyette Change -{min,max}depth argument name from n to depth so that the
earlier statement concerning n being prefaced by a plus or minus.
(These exceptions to the +/- rule noted by kre@)

While here, fix markup error. .Em for emphasis (stress) rather
than .Ar :)
 1.81 17-May-2014  apb Add an example with find ... -exec sh -c ....
 1.80 08-Feb-2013  wiz branches: 1.80.6;
Add serial commas.
From Bug Hunting.
 1.79 13-Oct-2012  njoly Remove a few unneeded Pp macros.
 1.78 26-Aug-2012  wiz branches: 1.78.2;
- improve spelling;
- improve wording;
- complement list of primaries that prevent `-print' from being
used implicitly;
- bump date.

Patch from Bug Hunting.
 1.77 16-Aug-2012  wiz Various improvements:
- remove redundant mentioning of option names within their description;
- improve (and make consistent) punctuation;
- add missing empty line;
- remove superfluous white space;
- extend `-iname' primary description (copying text from `-name');
- general wording improvements;
- improve macro usage;
- remove double spaces from examples (it's readable well without);
- reference re_format(7) in `SEE ALSO' (as it's mentioned in the
text several times);
- bump date.

From Bug Hunting.
 1.76 07-Jul-2012  wiz - Even if it may be obvious, actually explain what ``{}'' means
with ``-exec ... {} +'';
- make wording more consistent;
- bump date.

From Bug Hunting.
 1.75 27-Jun-2012  jdf Small fix: Changed 'Nm .' to 'Nm' (introduced by me before).
 1.74 27-Jun-2012  jdf Various formatting changes:
* Remove superfluous Pp macro (fixes mandoc(1) warning)
* use Xr macro instead of Nm where appropriate
* escape punctuation (so Ic actually 'sees' it) (fixed mandoc(1) warning)
* remove redundant argument to successive Nm macros
* remove double spaces

Patch supplied by Bug Hunting.
 1.73 20-Jun-2012  wiz Improve wording and macro usage; bump date.
From Bug Hunting.
 1.72 22-Mar-2012  wiz Fix whitespace nits. Suggested by Bug Hunting.
 1.71 24-Sep-2011  apb branches: 1.71.2;
Updates to the find(1) man page, based on PR 45381 from Greg Woods,
with additional changes by myself.
 1.70 09-Sep-2010  wiz Fix typos found by Ryo HAYASAKA in PR 43857.
While here, split file systems that grew together.
 1.69 06-Nov-2009  dsl Clarify (hopefully) the description of -remove.
Fixes PR/38987
 1.68 15-Oct-2009  joerg Use -compact + explicit .Pp instead of .sp with negative line length.
 1.67 04-Jan-2009  wiz Fix first part of PR 38987 by Robert Elz:
.Dq needs punctuation quoted to mark it up.

I leave 2) and 3) of that PR open for someone else...
 1.66 19-Jul-2007  daniel branches: 1.66.16;
Add the '-E' option to interpret regexes as extended regexes. While we
are here, fix ordering in usage information by putting '-X' in the proper
place.

Addition of '-E' was discussed on tech-userlevel.
 1.65 08-Mar-2007  wiz Remove macrobreaking whitespace.
 1.64 08-Feb-2007  perry Add a missing "can". Update date.
 1.63 06-Feb-2007  perry Document -rm as an alias for -delete, and document that both -delete
and -rm are extensions.
 1.62 06-Feb-2007  elad Add -delete from FreeBSD.
 1.61 02-Feb-2007  wiz Fix typo.
 1.60 01-Feb-2007  christos document -xdev [from Anon Ymous]
 1.59 07-Oct-2006  apb Document "find ... -exec ... {} +". Also make some other minor updates.

Changes initially supplied by John Hawkinson in PR 20470, but edited by me.

/msg wizd: search for ".sp"
 1.58 07-Oct-2006  apb Add some missing entries in lists, and some serial commas.
Inspired by PR 20470 from John Hawkinson.
 1.57 23-Sep-2006  uebayasi PR32022 - Clarify find(1) syntax documentation about parenthesized expressions
and the -f option (explicit hierarchy specifier). From "Sander Bos, with
credits to Peter Bex".

Bump date.
 1.56 20-Feb-2006  jschauma Add a new primary '-exit n':
This primary causes find to stop traversing the filesystem and
exit immediately if a previous condition was met. If no value is
specified, the exit value will be 0, else n. Note that other
primaries will be evaluated and acted upon before exiting.

Ok matt@, garbled@.
 1.55 09-Nov-2005  reed Add -false switch. From man page:

-false This primary always evaluates to false. This can be used follow-
ing a primary that caused the expression to be true to make the
expression to be false. This can be useful after using a -fprint
primary so it can continue to the next expression (using an -or
operator, for example).

This was brought up on the tech-userlevel list in October.

Using -fprint on findutils or new NetBSD find(1) does not do what
I wanted. For example, if saving results of all files that start
with a vowel or saving results of all files owned by group operator,
then the list of files owned by group operator would not include
the files starting with a vowel.

findutils's find has a workaround for this with -false and also a
"," comma opeator. (I made add this comma operator later; you can use
the comma to perform multiple independent tests.)
 1.54 12-Oct-2005  wiz Bump date for previous.
 1.53 12-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

Note that this example will NOT include entry in file2 if it is
matched in first expression. (This also is same behaviour as
findutils, and I have implemented a -false primary to handle that.
I will commit it later.)

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.

This was discussed on tech-userlevel.
 1.52 10-Aug-2005  mrg add a "file" to the arguments that isn't enclosed in square brackets
making it clear that at least one file/directory argument is required
in both the manual and usage. "find" with no args currently barfs but
these documents implied it would do something useful.
 1.51 19-Apr-2004  lukem tweak roff in previous
 1.50 19-Apr-2004  lukem Use "sysctl vfs.generic.fstypes" to determine the list of available fstypes.
 1.49 31-Mar-2004  wiz Bump date for previous, and sort a bit.
 1.48 30-Mar-2004  heas Mention -type w, which is coded as a synonym for W (whitespace).
 1.47 07-Aug-2003  agc branches: 1.47.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.46 03-Aug-2003  provos Implement -iname for case insensitive matching on file names.
From freebsd/openbsd. Approved by jaromir@, manu@, perry@.
 1.45 26-Jun-2003  wiz Change macro usage so it works correctly with 1.19.
 1.44 04-Apr-2003  wiz Add missing "to be". From Jim Bernard in PR 21008.
 1.43 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.42 23-Feb-2003  jhawk markup: the ";" for -exec, -ok, and -execdir is a seperate word from
the last argument
 1.41 30-Jan-2003  jhawk Obey preceding - and + on -user when a numeric uid is specified (only).
Our behavior is now consistent with Solaris, and more useful than previous.
 1.40 26-Jan-2003  matt With -printx also qoute $ and ` (since they are shell metacharaters).
 1.39 01-Oct-2002  wiz Lose a trailing space.
 1.38 28-Sep-2002  wiz Clean up after recent changes.
Some notes:
\- is for minus signs only.
Closing braces and punctuation after a macro should definitly not be
on the next line, but at the end of the macro line, separated with spaces
from the macro argument and each other. Otherwise, unwanted whitespace
appears.
 1.37 28-Sep-2002  grant bump date for latest changes.
 1.36 27-Sep-2002  grant New sentence, new line and minor mdoc cleanup.
 1.35 27-Sep-2002  provos support for -empty, -execdir, -mindepth, -maxdepth to match other UNIX-like
systems. based on work by tholo@openbsd.org. approved by perry.
 1.34 16-Sep-2002  thorpej -path is an extension -- say so.
 1.33 08-Feb-2002  ross branches: 1.33.2;
Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.32 02-Dec-2001  kleink Since we've already been down that road with -cnewer, support GNU find(1)'s
-anewer as well.
 1.31 01-Dec-2001  wiz Punctuation fix, sort SEE ALSO, sort sections, drop a .Pp.
 1.30 01-Dec-2001  wiz Whitespace cleanup.
 1.29 01-Dec-2001  kleink Add a "cnewer" primary which evaluates true if a file has a more recent
ctime than its argument.

From kre in PR bin/14802; originally suggested name was "updated" but
renamed due to GNU find(1) being prior art for this functionality.
 1.28 06-Jul-2001  abs space after section number in .Xr
 1.27 11-Jul-2000  kleink -s: Replace the reference to strcmp(3) with a functional description.
 1.26 16-Mar-2000  enami Fix typo.
 1.25 13-Mar-2000  itohy Add -s in usage.
 1.24 10-Mar-2000  itohy Describe -s (sort) option.
Corrections are highly appreciated.
 1.23 20-Jul-1999  kleink Mention -iregex and -regex primaries being non-standard extensions.
 1.22 20-Jul-1999  cgd add -regex and -iregex primaries which, like GNU find's primaries of the
same name, match files' entire paths against regular expressions.
-regex is case sensitive, -iregex is case-insensitive. Note that these
primaries are _not_ entirely compatible with the GNU find primaries,
because their BREs appear to support alternation with \| whereas our BREs
do not. Also note there are no primaries which provide extended regular
expressions matching, though if they are desired they would be trivial
to implement.
 1.21 30-Apr-1999  simonb Add '-h' to synopsis - from Nathan Williams.
 1.20 07-Mar-1999  mycroft branches: 1.20.2;
Fix minor formatting error.
 1.19 19-Jan-1999  simonb Add -{a,c,m}min to STANDARDS section (via Klaus Klein)
 1.18 16-Jan-1999  simonb Add GNU-style -{a,c,m}min primaries.
 1.17 12-Jan-1999  lukem Add support for -printx, which quotes pathnames in an xargs friendly way.
From [bin/6790] by Eric Fischer <eric@fudge.uchicago.edu>
 1.16 03-Jan-1999  lukem Add support for "-flags [-]flags", which matches the file flags in a
similar way that "-perm [-]mode" matches the file mode.
 1.15 03-Jan-1999  lukem args to -perm are "-perm [-]mode" not "-perm [-mode]"
 1.14 27-May-1998  msaitoh eliminate a duplicated -X entry
 1.13 02-Feb-1998  mrg merge lite2, sans getvfsbyname in functions.c (waiting on libc)
 1.12 19-Oct-1997  lukem fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix)
 1.11 09-Jan-1997  tls RCS ID police
 1.10 21-May-1996  mrg add support for whiteouts. pr#2394 (Mike Long <mike.long@analog.com>)
 1.9 14-Jan-1996  thorpej Document the -follow option, per David Brownlee <abs@mono.city.ac.uk>
in PR #1113.
 1.8 18-Jul-1994  cgd fix behaviour when adding -print
 1.7 14-Apr-1994  cgd branches: 1.7.2;
fstypes will be strings soon
 1.6 30-Dec-1993  jtc Merged our bugfixes with the 4.4BSD find from uunet.
 1.5 29-Dec-1993  jtc Update the list of primaries that are extensions of POSIX.2.
 1.4 27-Oct-1993  jtc Added -print0 (like GNU find). This will allow file names that contain
newlines to be correctly interpreted by programs that process find
output.
 1.3 01-Aug-1993  mycroft Add RCS indentifiers.
 1.2 24-Mar-1993  cgd added support for "kernfs" and "fdesc" to -fstype
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 18-Jul-1994  cgd udpated from trhunk; needed fro release building scripts
 1.20.2.2 20-Aug-1999  cgd pull up revs 1.22-1.23 from trunk. (cgd)
 1.20.2.1 30-Apr-1999  perry pullup 1.20->1.21 (simonb)
 1.33.2.1 01-Dec-2002  he Pull up revision 1.34 (requested by thorpej in ticket #838):
-path is an extension, so document it as such.
 1.47.2.1 31-Mar-2004  tron branches: 1.47.2.1.2;
Pull up revision 1.48 (requested by heas in ticket #25):
Mention -type w, which is coded as a synonym for W (whitespace).
 1.47.2.1.2.2 11-Oct-2005  reed Revert changes. I accidently committed to netbsd-2.
 1.47.2.1.2.1 11-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

This was discussed on tech-userlevel.

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.
 1.66.16.2 19-Jul-2007  daniel Add the '-E' option to interpret regexes as extended regexes. While we
are here, fix ordering in usage information by putting '-X' in the proper
place.

Addition of '-E' was discussed on tech-userlevel.
 1.66.16.1 19-Jul-2007  daniel file find.1 was added on branch matt-mips64 on 2007-07-19 07:49:31 +0000
 1.71.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.71.2.2 30-Oct-2012  yamt sync with head
 1.71.2.1 17-Apr-2012  yamt sync with head
 1.78.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.78.2.2 25-Feb-2013  tls resync with head
 1.78.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.80.6.1 10-Aug-2014  tls Rebase.
 1.30 13-Jun-2016  pgoyette Add new primaries -asince, -csince, and -since to compare file's
attributes against a user-specified timestamp (rather than the
attributes of a reference file).

Update the parse routines so they have access to the name of the
option being parsed. This enables accurate error reporting for
"aliases" of primaries.

Now that aliases work, introduce some aliases for consistency with
Gnu findutils.
 1.29 20-Mar-2012  matt Use C89 function definitions
 1.28 18-Mar-2012  dholland Avoid testing a possibly uninitialized errno value when using -exit.
Closes PR 44973 (change is a somewhat more principled equivalent of
the patch suggested there) although I cannot replicate the reported
behavior unless I explicitly prepare errno with a nonzero value before
the fts_read loop.
 1.27 28-Dec-2010  christos branches: 1.27.6;
only setup siginfo handler if we have a tty.
 1.26 27-Dec-2010  christos The SIGINFO changes made the sigprocmask syscalls dominate all the rest:
- Don't bother dealing with signal masks if we are not connected to a tty.
- Compute the blocking mask only once.
- Only do the block-unblock game only when we are going to do something
(execute, print a warning, etc.)
 1.25 25-Sep-2007  lukem revert previous thinko
 1.24 25-Sep-2007  lukem remove unnecessary #include
 1.23 11-Oct-2006  apb branches: 1.23.8;
De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.22 07-Oct-2006  apb Add support for "find ... -exec ... {} +".

The code is from John Hawkinson in PR 20470. I adapted it to current,
and made some KNF and comment changes.
 1.21 20-Feb-2006  jschauma Add a new primary '-exit n':
This primary causes find to stop traversing the filesystem and
exit immediately if a previous condition was met. If no value is
specified, the exit value will be 0, else n. Note that other
primaries will be evaluated and acted upon before exiting.

Ok matt@, garbled@.
 1.20 12-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

Note that this example will NOT include entry in file2 if it is
matched in first expression. (This also is same behaviour as
findutils, and I have implemented a -false primary to handle that.
I will commit it later.)

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.

This was discussed on tech-userlevel.
 1.19 30-Mar-2004  heas Do not skip whiteout files returned by fts_read(), which only returns them if
requested.

Patch from Dave Huang in PR bin/5419.
 1.18 07-Aug-2003  agc branches: 1.18.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.17 22-May-2003  yamt protect from signals properly.
(fix crashes when get SIGINFO.)
 1.16 22-May-2003  yamt rename a global variable, 'entry', to 'g_entry'.
it was confusing because we have many local 'entry' variable.
 1.15 27-Sep-2002  provos support for -empty, -execdir, -mindepth, -maxdepth to match other UNIX-like
systems. based on work by tholo@openbsd.org. approved by perry.
 1.14 16-Mar-2000  enami Cosmetic changes.
 1.13 10-Mar-2000  kleink Use strcoll() to sort directory entries.
 1.12 10-Mar-2000  itohy Add -s (sort) option, which causes entries in each directory sorted.
Similar to FreeBSD's.
 1.11 21-Feb-1998  christos Simplify the function calling code and warnsify.
 1.10 02-Feb-1998  mrg merge lite2, sans getvfsbyname in functions.c (waiting on libc)
 1.9 19-Oct-1997  lukem fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix)
 1.8 09-Jan-1997  tls RCS ID police
 1.7 23-Jun-1996  mrg KNF.
 1.6 18-Jul-1994  cgd fix behaviour when adding -print
 1.5 30-Dec-1993  jtc branches: 1.5.2;
Merged our bugfixes with the 4.4BSD find from uunet.
 1.4 30-Dec-1993  jtc Remove special case for root-level symlinks.
 1.3 01-Oct-1993  jtc Use *->fts_errno instead of errno after fts_read(). The fts manpage
indicates that the fts_errno will be set to the correct value, but there
are no guarentees about errno.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 18-Jul-1994  cgd udpated from trhunk; needed fro release building scripts
 1.18.2.1 31-Mar-2004  tron branches: 1.18.2.1.2;
Pull up revision 1.19 (requested by heas in ticket #25):
Do not skip whiteout files returned by fts_read(), which only returns them if
requested.
Patch from Dave Huang in PR bin/5419.
 1.18.2.1.2.2 11-Oct-2005  reed Revert changes. I accidently committed to netbsd-2.
 1.18.2.1.2.1 11-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

This was discussed on tech-userlevel.

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.
 1.23.8.1 06-Nov-2007  matt sync with HEAD
 1.27.6.1 17-Apr-2012  yamt sync with head
 1.28 22-Jan-2022  christos Use /dev/tty for SIGINFO
Fix some size_t<->int
 1.27 18-Mar-2021  cheusov find: use POSIX type uint32_t instead of u_int32_t
 1.26 13-Jun-2016  pgoyette Add new primaries -asince, -csince, and -since to compare file's
attributes against a user-specified timestamp (rather than the
attributes of a reference file).

Update the parse routines so they have access to the name of the
option being parsed. This enables accurate error reporting for
"aliases" of primaries.

Now that aliases work, introduce some aliases for consistency with
Gnu findutils.
 1.25 04-May-2013  uebayasi find(1): Compare timestamp in nsec scale in -anewer/-cnewer/-newer.
 1.24 06-Feb-2007  elad branches: 1.24.34; 1.24.40;
Add -delete from FreeBSD.
 1.23 11-Oct-2006  apb De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.22 07-Oct-2006  apb Add support for "find ... -exec ... {} +".

The code is from John Hawkinson in PR 20470. I adapted it to current,
and made some KNF and comment changes.
 1.21 20-Feb-2006  jschauma Add a new primary '-exit n':
This primary causes find to stop traversing the filesystem and
exit immediately if a previous condition was met. If no value is
specified, the exit value will be 0, else n. Note that other
primaries will be evaluated and acted upon before exiting.

Ok matt@, garbled@.
 1.20 09-Nov-2005  reed Add -false switch. From man page:

-false This primary always evaluates to false. This can be used follow-
ing a primary that caused the expression to be true to make the
expression to be false. This can be useful after using a -fprint
primary so it can continue to the next expression (using an -or
operator, for example).

This was brought up on the tech-userlevel list in October.

Using -fprint on findutils or new NetBSD find(1) does not do what
I wanted. For example, if saving results of all files that start
with a vowel or saving results of all files owned by group operator,
then the list of files owned by group operator would not include
the files starting with a vowel.

findutils's find has a workaround for this with -false and also a
"," comma opeator. (I made add this comma operator later; you can use
the comma to perform multiple independent tests.)
 1.19 12-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

Note that this example will NOT include entry in file2 if it is
matched in first expression. (This also is same behaviour as
findutils, and I have implemented a -false primary to handle that.
I will commit it later.)

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.

This was discussed on tech-userlevel.
 1.18 07-Aug-2003  agc branches: 1.18.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.17 03-Aug-2003  provos Implement -iname for case insensitive matching on file names.
From freebsd/openbsd. Approved by jaromir@, manu@, perry@.
 1.16 23-Feb-2003  jhawk delint: trailing commas in enum definitions are prohibitted
knf: instantiate macros with #define<TAB>, not <SPACE>, and also align.
 1.15 27-Sep-2002  provos support for -empty, -execdir, -mindepth, -maxdepth to match other UNIX-like
systems. based on work by tholo@openbsd.org. approved by perry.
 1.14 02-Dec-2001  kleink Since we've already been down that road with -cnewer, support GNU find(1)'s
-anewer as well.
 1.13 01-Dec-2001  kleink Add a "cnewer" primary which evaluates true if a file has a more recent
ctime than its argument.

From kre in PR bin/14802; originally suggested name was "updated" but
renamed due to GNU find(1) being prior art for this functionality.
 1.12 20-Jul-1999  cgd add -regex and -iregex primaries which, like GNU find's primaries of the
same name, match files' entire paths against regular expressions.
-regex is case sensitive, -iregex is case-insensitive. Note that these
primaries are _not_ entirely compatible with the GNU find primaries,
because their BREs appear to support alternation with \| whereas our BREs
do not. Also note there are no primaries which provide extended regular
expressions matching, though if they are desired they would be trivial
to implement.
 1.11 16-Jan-1999  simonb branches: 1.11.2;
Add GNU-style -{a,c,m}min primaries.
 1.10 12-Jan-1999  lukem Add support for -printx, which quotes pathnames in an xargs friendly way.
From [bin/6790] by Eric Fischer <eric@fudge.uchicago.edu>
 1.9 03-Jan-1999  lukem Add support for "-flags [-]flags", which matches the file flags in a
similar way that "-perm [-]mode" matches the file mode.
 1.8 21-Feb-1998  christos Simplify the function calling code and warnsify.
 1.7 02-Feb-1998  mrg merge lite2, sans getvfsbyname in functions.c (waiting on libc)
 1.6 09-Jan-1997  tls RCS ID police
 1.5 30-Dec-1993  jtc Merged our bugfixes with the 4.4BSD find from uunet.
 1.4 27-Oct-1993  jtc Added -print0 (like GNU find). This will allow file names that contain
newlines to be correctly interpreted by programs that process find
output.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 24-Mar-1993  cgd fixed fact that "rdonly" wasn't supported by -fstype, but the man
page said it was. also fixed multiple fstype checks on the same
partition
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.2.1 20-Aug-1999  cgd pull up rev 1.12 from trunk. (cgd)
 1.18.4.2 11-Oct-2005  reed Revert changes. I accidently committed to netbsd-2.
 1.18.4.1 11-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

This was discussed on tech-userlevel.

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.
 1.24.40.1 23-Jun-2013  tls resync from head
 1.24.34.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.81 05-Feb-2024  andvar fix various typos in comments.
 1.80 01-Apr-2023  christos PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD
 1.79 18-Mar-2021  cheusov branches: 1.79.6;
find: use POSIX strtoll(3) instead of legacy strtoq(3)
 1.78 18-Mar-2021  cheusov find: use POSIX type uint32_t instead of u_int32_t
 1.77 04-Sep-2018  kre branches: 1.77.2;
Inspired by PR pkg/53543

When calculating the length of the args that can be
appended in a "find .... -exec something {} +"
usage, remember to allow for the arg pointers, which
form part of what is allowed in ARG_MAX.

From a fairly empty installation of HEAD on amd64
and with a "/tmp/args" command that simply prints
its arg count, and the length of the arg strings,
with this mod I see ..

netbsd# find / -exec /tmp/args {} +
Argc 5000 Arglen 107645
Argc 5000 Arglen 151324
Argc 5000 Arglen 187725
Argc 5000 Arglen 206591
Argc 5000 Arglen 172909
Argc 5000 Arglen 186264
Argc 5000 Arglen 167906
Argc 2881 Arglen 98260

The upper limit of 5000 args is in the code.

Using the biggest of those, 5000
args, plus 206591 bytes of strings
uses 246591 bytes total (this excludes
the command name, so add a few more).
That's fairly close to the ARG_MAX
of 262144.

On another system (with longer paths) I see:
(this is just a small part of the output, using a
different version of the dummy command, and a
slightly different invocation)

Args: 4546 Len 218030
Args: 4878 Len 217991
Args: 4813 Len 218028
Args: 4803 Len 218029

There, 4878*8 + 217991 == 257015 which is about
as close as we'd want to come to the arg limit.

XXX pullup -8
 1.76 13-Jun-2017  christos branches: 1.76.4; 1.76.6;
PR/52295: Anthony Mallet: find -delete: "relative path not safe" with absolute
paths ... Fix from OpenBSD
 1.75 13-Jun-2016  pgoyette branches: 1.75.8;
Fix missing quote. Resolve automated test failure.
 1.74 13-Jun-2016  pgoyette Add new primaries -asince, -csince, and -since to compare file's
attributes against a user-specified timestamp (rather than the
attributes of a reference file).

Update the parse routines so they have access to the name of the
option being parsed. This enables accurate error reporting for
"aliases" of primaries.

Now that aliases work, introduce some aliases for consistency with
Gnu findutils.
 1.73 12-Jun-2016  dholland Extend the numeric handling for uids with -user to gids with -group, and
document it. Leftover bit of PR 46158.
 1.72 04-May-2013  uebayasi branches: 1.72.6;
find(1): Compare timestamp in nsec scale in -anewer/-cnewer/-newer.
 1.71 26-Aug-2012  wiz branches: 1.71.2;
Make order of words in comment consistent with that within other
comments (helps with search actions).

Patch from Bug Hunting.
 1.70 05-May-2012  dholland rest of previous.
BQS: 1. dholland: 0.
 1.69 05-May-2012  dholland typo in comment
 1.68 20-Mar-2012  matt Use C89 function definitions
 1.67 22-Sep-2011  christos branches: 1.67.2;
Fix unchecked malloc, check for overflow (Maksymilian Arciemowicz)
While here, remove unused casts, fix types.
 1.66 24-Feb-2011  jmcneill Don't error out while searching for empty directories, from FreeBSD:

http://lists.freebsd.org/pipermail/svn-src-head/2010-December/022913.html
 1.65 06-Jan-2011  dholland branches: 1.65.2;
Fix "-exec blah blah {} +" so it only matches when the {} is last, as
per the standard. Per (brief) discussion on tech-userlevel.

There should really be a form where you can do the equivalent of
"-exec blah {} blah +", but I think we're going to need to call it
something other than -exec. As it is it's sort of surprising that the
standards people didn't add a different name -- note what happens if
you try to do something like "find ... -exec expr {} + 2 \;".
 1.64 19-Jul-2007  daniel branches: 1.64.16;
Add the '-E' option to interpret regexes as extended regexes. While we
are here, fix ordering in usage information by putting '-X' in the proper
place.

Addition of '-E' was discussed on tech-userlevel.
 1.63 17-Jul-2007  christos eliminate MFSNAMELEN
 1.62 06-Feb-2007  elad Add -delete from FreeBSD.
 1.61 02-Feb-2007  christos fix spello (from Anon Ymous)
 1.60 14-Dec-2006  he Adapt find to the move of string_to_flags() and flags_to_string() to
libutil.
 1.59 09-Nov-2006  christos eliminate alloca use.
 1.58 12-Oct-2006  tacha All members of PLAN should be initialized.
 1.57 11-Oct-2006  apb De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.56 07-Oct-2006  apb Add support for "find ... -exec ... {} +".

The code is from John Hawkinson in PR 20470. I adapted it to current,
and made some KNF and comment changes.
 1.55 26-Aug-2006  christos More programs using efun.
 1.54 10-May-2006  mrg quell GCC 4.1 uninitialised variable warnings.

XXX: we should audit the tree for which old ones are no longer needed
after getting the older compilers out of the tree..
 1.53 20-Feb-2006  jschauma Add a new primary '-exit n':
This primary causes find to stop traversing the filesystem and
exit immediately if a previous condition was met. If no value is
specified, the exit value will be 0, else n. Note that other
primaries will be evaluated and acted upon before exiting.

Ok matt@, garbled@.
 1.52 09-Nov-2005  reed Add -false switch. From man page:

-false This primary always evaluates to false. This can be used follow-
ing a primary that caused the expression to be true to make the
expression to be false. This can be useful after using a -fprint
primary so it can continue to the next expression (using an -or
operator, for example).

This was brought up on the tech-userlevel list in October.

Using -fprint on findutils or new NetBSD find(1) does not do what
I wanted. For example, if saving results of all files that start
with a vowel or saving results of all files owned by group operator,
then the list of files owned by group operator would not include
the files starting with a vowel.

findutils's find has a workaround for this with -false and also a
"," comma opeator. (I made add this comma operator later; you can use
the comma to perform multiple independent tests.)
 1.51 12-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

Note that this example will NOT include entry in file2 if it is
matched in first expression. (This also is same behaviour as
findutils, and I have implemented a -false primary to handle that.
I will commit it later.)

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.

This was discussed on tech-userlevel.
 1.50 01-Oct-2005  christos fix setmode error handling.
 1.49 28-Dec-2004  atatat Attack of the whiteout police, including the "fix whitespace problems"
department followed by the "and fix the the ifdefs as well" brigade,
leading to a janitorial "just combine those two" strike team.
 1.48 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.47 30-Mar-2004  heas Whitespace nit
 1.46 07-Aug-2003  agc branches: 1.46.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.45 03-Aug-2003  provos Implement -iname for case insensitive matching on file names.
From freebsd/openbsd. Approved by jaromir@, manu@, perry@.
 1.44 12-Jul-2003  itojun strlcpy
 1.43 30-Jan-2003  jhawk Obey preceding - and + on -user when a numeric uid is specified (only).
Our behavior is now consistent with Solaris, and more useful than previous.

Unfortunately we end up strtol()-ing twice (once via atoi()) to avoid
changing find_parsenum().
 1.42 26-Jan-2003  matt With -printx also qoute $ and ` (since they are shell metacharaters).
 1.41 27-Sep-2002  provos support for -empty, -execdir, -mindepth, -maxdepth to match other UNIX-like
systems. based on work by tholo@openbsd.org. approved by perry.
 1.40 02-Dec-2001  kleink Since we've already been down that road with -cnewer, support GNU find(1)'s
-anewer as well.
 1.39 01-Dec-2001  kleink Add a "cnewer" primary which evaluates true if a file has a more recent
ctime than its argument.

From kre in PR bin/14802; originally suggested name was "updated" but
renamed due to GNU find(1) being prior art for this functionality.
 1.38 21-Sep-2001  enami Reallocate memory correctly while substituting the braces.
 1.37 18-Sep-2001  simonb Back out previous vfork->fork change now that the cause of the problem
(execvp) has been fixed.
 1.36 14-Sep-2001  simonb Use fork() instead of vfork(). The child calls execvp(), which calls
strdup(), which calls malloc()...

Fixes problem with "find .. -exec" growing as reported by Kazushi Marukawa
on current-users@.
 1.35 05-Feb-2001  christos fixed nested externs
 1.34 10-Oct-2000  enami - The type of return value of setmode is a void * and getmode takes it,
rather than mode_t *.
- Free the storage allocated by setmode unless it is obvious that program
exits immediately.
 1.33 16-Mar-2000  enami Cosmetic changes.
 1.32 09-Nov-1999  drochner Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
 1.31 20-Jul-1999  cgd branches: 1.31.4;
add -regex and -iregex primaries which, like GNU find's primaries of the
same name, match files' entire paths against regular expressions.
-regex is case sensitive, -iregex is case-insensitive. Note that these
primaries are _not_ entirely compatible with the GNU find primaries,
because their BREs appear to support alternation with \| whereas our BREs
do not. Also note there are no primaries which provide extended regular
expressions matching, though if they are desired they would be trivial
to implement.
 1.30 04-Feb-1999  kleink branches: 1.30.2;
Don't choke on file size specifications (legitimately) exceeding LONG_MAX.
 1.29 16-Jan-1999  simonb Add GNU-style -{a,c,m}min primaries.
 1.28 12-Jan-1999  lukem Add support for -printx, which quotes pathnames in an xargs friendly way.
From [bin/6790] by Eric Fischer <eric@fudge.uchicago.edu>
 1.27 03-Jan-1999  lukem Add support for "-flags [-]flags", which matches the file flags in a
similar way that "-perm [-]mode" matches the file mode.
 1.26 06-Nov-1998  christos we don't need sys/ucred.h
 1.25 14-Oct-1998  wsanchez init mask to silence -Wall
 1.24 21-Feb-1998  christos Simplify the function calling code and warnsify.
 1.23 03-Feb-1998  mrg remove getvfsbyname cruft.
 1.22 02-Feb-1998  mrg merge lite2, sans getvfsbyname in functions.c (waiting on libc)
 1.21 19-Oct-1997  lukem fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix)
 1.20 01-Feb-1997  matthias remove second RCS-Id line.
 1.19 30-Jan-1997  matthias finding whiteouts didn't work.
 1.18 09-Jan-1997  tls RCS ID police
 1.17 21-May-1996  mrg add support for whiteouts. pr#2394 (Mike Long <mike.long@analog.com>)
 1.16 18-Jun-1995  cgd don't assume f_fstypename is larger than MFSNAMELEN or is nul-terminated
 1.15 18-Oct-1994  mycroft Get rid of a redundant sanity check.
 1.14 18-Oct-1994  mycroft Always save both the mount flags and the file system type when crossing a
mount point. From John Kohl.
 1.13 14-Apr-1994  cgd branches: 1.13.2;
fstypes will be strings soon
 1.12 16-Feb-1994  andrew -nouser and -nogroup tests were negated.
 1.11 21-Jan-1994  jtc Flush stdout and stderr before processing an -exec (or -ok), so the output
of the exec'd command and find's output will be correctly interspersed.
(Bug noticed by Terry Lambert, of FreeBSD. Fix by me).
 1.10 30-Dec-1993  jtc Merged our bugfixes with the 4.4BSD find from uunet.
 1.9 27-Oct-1993  jtc Added -print0 (like GNU find). This will allow file names that contain
newlines to be correctly interpreted by programs that process find
output.
 1.8 16-Sep-1993  cgd fix to the 'size' primary; -size <n>c didn't work. from
Thomas Eberhardt <thomas@mathematik.uni-Bremen.de>
 1.7 06-Aug-1993  deraadt for new fts library
 1.6 01-Aug-1993  mycroft Add RCS identifiers.
 1.5 16-Jun-1993  jtc Update source to use posix fnmatch
 1.4 10-Apr-1993  mycroft Reverse sense of fnmatch() to match POSIX.
 1.3 24-Mar-1993  cgd added support for "kernfs" and "fdesc" to -fstype
 1.2 24-Mar-1993  cgd fixed fact that "rdonly" wasn't supported by -fstype, but the man
page said it was. also fixed multiple fstype checks on the same
partition
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.13.2.1 18-Oct-1994  cgd from trunk.
 1.30.2.1 20-Aug-1999  cgd pull up rev 1.31 from trunk. (cgd)
 1.31.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.46.4.2 11-Oct-2005  reed Revert changes. I accidently committed to netbsd-2.
 1.46.4.1 11-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

This was discussed on tech-userlevel.

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.
 1.64.16.2 19-Jul-2007  daniel Add the '-E' option to interpret regexes as extended regexes. While we
are here, fix ordering in usage information by putting '-X' in the proper
place.

Addition of '-E' was discussed on tech-userlevel.
 1.64.16.1 19-Jul-2007  daniel file function.c was added on branch matt-mips64 on 2007-07-19 07:49:31 +0000
 1.65.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.67.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.67.2.3 30-Oct-2012  yamt sync with head
 1.67.2.2 23-May-2012  yamt sync with head.
 1.67.2.1 17-Apr-2012  yamt sync with head
 1.71.2.1 23-Jun-2013  tls resync from head
 1.72.6.1 30-Oct-2018  sborrill Pull up the following revisions(s) (requested by mrg in ticket #1642):
usr.bin/find/function.c: revision 1.77

When calculating the length of the args that can be
appended in a "find .... -exec something {} +"
usage, remember to allow for the arg pointers, which
form part of what is allowed in ARG_MAX.
 1.75.8.3 04-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1879):

usr.bin/find/main.c: revision 1.32
usr.bin/find/function.c: revision 1.80

PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD
 1.75.8.2 10-Sep-2018  martin Pull up following revision(s) (requested by kre in ticket #1016):

usr.bin/find/function.c: revision 1.77

Inspired by PR pkg/53543

When calculating the length of the args that can be
appended in a "find .... -exec something {} +"
usage, remember to allow for the arg pointers, which
form part of what is allowed in ARG_MAX.

From a fairly empty installation of HEAD on amd64
and with a "/tmp/args" command that simply prints
its arg count, and the length of the arg strings,
with this mod I see ..

netbsd# find / -exec /tmp/args {} +
Argc 5000 Arglen 107645
Argc 5000 Arglen 151324
Argc 5000 Arglen 187725
Argc 5000 Arglen 206591
Argc 5000 Arglen 172909
Argc 5000 Arglen 186264
Argc 5000 Arglen 167906
Argc 2881 Arglen 98260

The upper limit of 5000 args is in the code.

Using the biggest of those, 5000
args, plus 206591 bytes of strings
uses 246591 bytes total (this excludes
the command name, so add a few more).

That's fairly close to the ARG_MAX
of 262144.

On another system (with longer paths) I see:
(this is just a small part of the output, using a
different version of the dummy command, and a
slightly different invocation)

Args: 4546 Len 218030
Args: 4878 Len 217991
Args: 4813 Len 218028
Args: 4803 Len 218029

There, 4878*8 + 217991 == 257015 which is about
as close as we'd want to come to the arg limit.

XXX pullup -8
 1.75.8.1 15-Jun-2017  snj Pull up following revision(s) (requested by christos in ticket #40):
usr.bin/find/function.c: revision 1.76
PR/52295: Anthony Mallet: find -delete: "relative path not safe" with absolute
paths ... Fix from OpenBSD
 1.76.6.1 10-Jun-2019  christos Sync with HEAD
 1.76.4.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.77.2.1 04-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1701):

usr.bin/find/main.c: revision 1.32
usr.bin/find/function.c: revision 1.80

PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD
 1.79.6.1 04-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #305):

usr.bin/find/main.c: revision 1.32
usr.bin/find/function.c: revision 1.80

PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD
 1.21 31-Aug-2011  plunky NULL does not need a cast
 1.20 29-Dec-2008  christos fix dev_t format
 1.19 11-Oct-2006  apb De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.17 12-Jul-2003  itojun strlcpy
 1.16 19-Oct-2002  provos use readlink with bufsize - 1; approved thorpej.
 1.15 01-Aug-2002  christos Use LOGIN_NAME_MAX instead of UT_NAMELEN
delete include of utmp.h
 1.14 04-Jan-2001  lukem use %ll_ instead of the less standard %q_
 1.13 06-Nov-1998  christos make printf format more conservative
 1.12 27-Oct-1998  simonb For -ls output, change field widths to allow inodes up to 9,999,999 and
file sizes up to 999,999,999 bytes (and 999,999 blocks) without wobbly
lines. Also change device minor/major to be 3/5 digits (current maximum
is 4/7 digits - the 3/5 split is arbitary).
 1.11 14-Oct-1998  wsanchez include stdlib
 1.10 03-Mar-1998  thorpej Cast off_t to long long for printing with %qd.
 1.9 19-Oct-1997  lukem fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix)
 1.8 30-Jun-1997  jtc Changed format directive for printing number of blocks from %4ld to
%4qd as the st_blocks field is a int64_t. Fixes PR 3814.
 1.7 09-Jan-1997  tls RCS ID police
 1.6 24-Dec-1994  cgd kill some unnecessary casts and decls
 1.5 27-Mar-1994  cgd off_t exp.
 1.4 06-Jan-1994  jtc st_blocks & st_size aren't quads (at least not yet).
 1.3 30-Dec-1993  jtc Merged our bugfixes with the 4.4BSD find from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.32 01-Apr-2023  christos PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD
 1.31 24-Jan-2013  christos branches: 1.31.22; 1.31.32; 1.31.40;
use O_CLOEXEC, wrap long line.
 1.30 16-Sep-2011  joerg branches: 1.30.2; 1.30.8;
Use __dead
 1.29 28-Dec-2010  christos only setup siginfo handler if we have a tty.
 1.28 21-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.27 19-Jul-2007  daniel branches: 1.27.12; 1.27.14;
Add the '-E' option to interpret regexes as extended regexes. While we
are here, fix ordering in usage information by putting '-X' in the proper
place.

Addition of '-E' was discussed on tech-userlevel.
 1.26 09-Nov-2006  christos eliminate alloca use.
 1.25 11-Oct-2006  apb De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.24 19-Oct-2005  elad Revert, as requested by cube@.
 1.23 19-Oct-2005  elad Strip trailing slashes before using the path.
PR/31869.
 1.22 10-Aug-2005  mrg add a "file" to the arguments that isn't enclosed in square brackets
making it clear that at least one file/directory argument is required
in both the manual and usage. "find" with no args currently barfs but
these documents implied it would do something useful.
 1.21 19-Jan-2005  mycroft Use FD_CLOEXEC (for -exec).
 1.20 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.19 27-Sep-2002  thorpej Need <string.h>.
 1.18 27-Sep-2002  provos support for -empty, -execdir, -mindepth, -maxdepth to match other UNIX-like
systems. based on work by tholo@openbsd.org. approved by perry.
 1.17 04-Aug-2000  enami If -H, clear FTS_LOGICAL and set FTS_PHYSICAL as well as FTS_COMFOLLOW.
If -L, clear FTS_PHYSICAL as well as FTS_COMFOLLOW.
 1.16 16-Mar-2000  enami Compare the return value of getopt(3) against -1 rather than EOF.
(while i'm here, one more cosometic change is performed).
 1.15 16-Mar-2000  enami Cosmetic changes.
 1.14 13-Mar-2000  itohy Add -s in usage.
 1.13 10-Mar-2000  kleink Use strcoll() to sort directory entries.
 1.12 10-Mar-2000  itohy Add -s (sort) option, which causes entries in each directory sorted.
Similar to FreeBSD's.
 1.11 29-Apr-1999  simonb Add 'h' to optstring. Fixes PR 7492 from Tom Trebisky.
 1.10 10-Feb-1998  cgd branches: 1.10.2;
allocate temporary storage for directory list, rather than clobbering
argv (yuck!).
 1.9 02-Feb-1998  mrg merge lite2, sans getvfsbyname in functions.c (waiting on libc)
 1.8 19-Oct-1997  lukem fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix)
 1.7 18-Oct-1997  lukem getopt returns -1 not EOF
 1.6 09-Jan-1997  tls RCS ID police
 1.5 24-Jan-1994  jtc Changed order of the subexpressions in a conditional to guard against
the case of zero length arguments.
 1.4 30-Dec-1993  jtc Merged our bugfixes with the 4.4BSD find from uunet.
 1.3 29-Dec-1993  jtc Changed to conform to POSIX.2, 4.24.4: the first argument that starts with
a -, or is a ! or a (, and all subsequent arguments shall be interpreted
as an expression ...
The behavior before this change can cause a non-option (eg -owner instead
of -user) to be interpreted as a file name. Depending on the expression
used, this could cause serious damage:

find . -owner jtc -exec rm \{\} \;

Will delete every file.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.2.1 29-Apr-1999  perry pullup 1.10->1.11 (simonb)
 1.27.14.2 19-Jul-2007  daniel Add the '-E' option to interpret regexes as extended regexes. While we
are here, fix ordering in usage information by putting '-X' in the proper
place.

Addition of '-E' was discussed on tech-userlevel.
 1.27.14.1 19-Jul-2007  daniel file main.c was added on branch matt-mips64 on 2007-07-19 07:49:31 +0000
 1.27.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.30.8.1 25-Feb-2013  tls resync with head
 1.30.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.31.40.1 04-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #305):

usr.bin/find/main.c: revision 1.32
usr.bin/find/function.c: revision 1.80

PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD
 1.31.32.1 04-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1701):

usr.bin/find/main.c: revision 1.32
usr.bin/find/function.c: revision 1.80

PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD
 1.31.22.1 04-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1879):

usr.bin/find/main.c: revision 1.32
usr.bin/find/function.c: revision 1.80

PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD
 1.16 10-Aug-2023  mrg avoid various use-after-free issues.

create a ptrdiff_t offset between the start of an allocation region and
some interesting pointer, so it can be adjusted with this offset after
realloc() returns. for pdisk(), realloc() is a locally inlind malloc()
and free() pair.

for mail(1), this required a little bit more effort as the old pointer
was passed into another file for fix-ups there, and that code needed to
be adjusted for offset vs old pointer usage.

found by GCC 12.
 1.15 22-Jan-2022  christos Use /dev/tty for SIGINFO
Fix some size_t<->int
 1.14 11-Oct-2006  apb De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.13 26-Aug-2006  christos More programs using efun.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.11 22-May-2003  yamt protect from signals properly.
(fix crashes when get SIGINFO.)
 1.10 22-May-2003  yamt rename a global variable, 'entry', to 'g_entry'.
it was confusing because we have many local 'entry' variable.
 1.9 27-Sep-2002  provos support for -empty, -execdir, -mindepth, -maxdepth to match other UNIX-like
systems. based on work by tholo@openbsd.org. approved by perry.
 1.8 21-Sep-2001  enami Reallocate memory correctly while substituting the braces.
 1.7 02-Feb-1998  mrg merge lite2, sans getvfsbyname in functions.c (waiting on libc)
 1.6 19-Oct-1997  lukem fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix)
 1.5 09-Jan-1997  tls RCS ID police
 1.4 23-Jun-1996  mrg fix incorrect (dated?) comment.
 1.3 30-Dec-1993  jtc Merged our bugfixes with the 4.4BSD find from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.9 11-Oct-2006  apb De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.7 02-Jan-1999  lukem fix bugs in handling of `!' operator:
* 'find . !' would coredump
* ! wouldn't correctly negate expressions in parenthesis

discovered and fixed by Dave Sainty <dave@dtsp.co.nz> in [bin/6412]
 1.6 21-Feb-1998  christos Simplify the function calling code and warnsify.
 1.5 19-Oct-1997  lukem fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix)
 1.4 09-Jan-1997  tls RCS ID police
 1.3 30-Dec-1993  jtc Merged our bugfixes with the 4.4BSD find from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.29 09-Aug-2021  andvar fix various typos in compatibility, mainly in comments.
 1.28 01-Nov-2020  mrg add support for '-not': GNU and thus worldly scripts compatibility.
 1.27 13-Jun-2016  pgoyette Add new primaries -asince, -csince, and -since to compare file's
attributes against a user-specified timestamp (rather than the
attributes of a reference file).

Update the parse routines so they have access to the name of the
option being parsed. This enables accurate error reporting for
"aliases" of primaries.

Now that aliases work, introduce some aliases for consistency with
Gnu findutils.
 1.26 06-Feb-2007  perry make -rm an alias for -delete
 1.25 06-Feb-2007  elad Add -delete from FreeBSD.
 1.24 11-Oct-2006  apb De-__P(), remove trailing spaces, sprinkle a few const, WARNS=4.
 1.23 20-Feb-2006  jschauma Add a new primary '-exit n':
This primary causes find to stop traversing the filesystem and
exit immediately if a previous condition was met. If no value is
specified, the exit value will be 0, else n. Note that other
primaries will be evaluated and acted upon before exiting.

Ok matt@, garbled@.
 1.22 09-Nov-2005  reed Add -false switch. From man page:

-false This primary always evaluates to false. This can be used follow-
ing a primary that caused the expression to be true to make the
expression to be false. This can be useful after using a -fprint
primary so it can continue to the next expression (using an -or
operator, for example).

This was brought up on the tech-userlevel list in October.

Using -fprint on findutils or new NetBSD find(1) does not do what
I wanted. For example, if saving results of all files that start
with a vowel or saving results of all files owned by group operator,
then the list of files owned by group operator would not include
the files starting with a vowel.

findutils's find has a workaround for this with -false and also a
"," comma opeator. (I made add this comma operator later; you can use
the comma to perform multiple independent tests.)
 1.21 12-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

Note that this example will NOT include entry in file2 if it is
matched in first expression. (This also is same behaviour as
findutils, and I have implemented a -false primary to handle that.
I will commit it later.)

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.

This was discussed on tech-userlevel.
 1.20 07-Aug-2003  agc branches: 1.20.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.19 03-Aug-2003  provos Implement -iname for case insensitive matching on file names.
From freebsd/openbsd. Approved by jaromir@, manu@, perry@.
 1.18 27-Sep-2002  provos support for -empty, -execdir, -mindepth, -maxdepth to match other UNIX-like
systems. based on work by tholo@openbsd.org. approved by perry.
 1.17 02-Dec-2001  kleink Since we've already been down that road with -cnewer, support GNU find(1)'s
-anewer as well.
 1.16 01-Dec-2001  kleink Add a "cnewer" primary which evaluates true if a file has a more recent
ctime than its argument.

From kre in PR bin/14802; originally suggested name was "updated" but
renamed due to GNU find(1) being prior art for this functionality.
 1.15 18-Oct-2000  jdolecek move the -and option in options[] table where it alphabetically belongs,
so that -amin works again
this fixes bin/11251
 1.14 16-Mar-2000  enami branches: 1.14.4;
Cosmetic changes.
 1.13 20-Jul-1999  cgd add -regex and -iregex primaries which, like GNU find's primaries of the
same name, match files' entire paths against regular expressions.
-regex is case sensitive, -iregex is case-insensitive. Note that these
primaries are _not_ entirely compatible with the GNU find primaries,
because their BREs appear to support alternation with \| whereas our BREs
do not. Also note there are no primaries which provide extended regular
expressions matching, though if they are desired they would be trivial
to implement.
 1.12 16-Jan-1999  simonb branches: 1.12.2;
Add GNU-style -{a,c,m}min primaries.
 1.11 12-Jan-1999  lukem Add support for -printx, which quotes pathnames in an xargs friendly way.
From [bin/6790] by Eric Fischer <eric@fudge.uchicago.edu>
 1.10 03-Jan-1999  lukem Add support for "-flags [-]flags", which matches the file flags in a
similar way that "-perm [-]mode" matches the file mode.
 1.9 21-Feb-1998  christos Simplify the function calling code and warnsify.
 1.8 02-Feb-1998  mrg merge lite2, sans getvfsbyname in functions.c (waiting on libc)
 1.7 19-Oct-1997  lukem fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix)
 1.6 09-Jan-1997  tls RCS ID police
 1.5 30-Dec-1993  jtc Merged our bugfixes with the 4.4BSD find from uunet.
 1.4 27-Oct-1993  jtc Added -print0 (like GNU find). This will allow file names that contain
newlines to be correctly interpreted by programs that process find
output.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 19-Apr-1993  mycroft Remove bogus option so as not to confuse bsearch().
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Sep-1995  jtc imported from 44lite2
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.12.2.1 20-Aug-1999  cgd pull up rev 1.13 from trunk. (cgd)
 1.14.4.1 18-Oct-2000  tv Pullup 1.15 [jdolecek]:
move the -and option in options[] table where it alphabetically belongs,
so that -amin works again
this fixes bin/11251
 1.20.4.2 11-Oct-2005  reed Revert changes. I accidently committed to netbsd-2.
 1.20.4.1 11-Oct-2005  reed This adds -fprint function. The primary name "-fprint" (but not the
code) comes from findutils; it behaves the same.

From my manpage addition:

-fprint filename
This primary always evaluates to true. This creates filename or
overwrites the file if it already exists. The file is created at
startup. It writes the pathname of the current file to this
file, followed by a newline character. The file will be empty if
no files are matched.

Here is an example usage:

find /etc \( -name "*pass*" -fprint file1 \) -o \( -group operator -fprint file2 \) -o -name "w*"

This was discussed on tech-userlevel.

This creates the file as command line argument parsing time.
If there is an error somewhere on that line, such as missing values
or mismatched parenthesis, then a file may still be created.
(Even if a later -fprint filename is unwritable.) This is similar
behaviour to findutils. (It has been suggested that this find could
be code to create the files in an extra stage after the command-line
argument parsing and before the actual function processing.)

I will add -fprintx and -fprint0 soon.

RSS XML Feed