Commit Graph

31 Commits

Author SHA1 Message Date
Oleksandr Tymoshenko
f2ef15fec4 Fix whiteout support in find(1)
find(1) ignores -type w passed to it. With this patch find(1) properly
identifies and prints whiteouts.

PR:		126384, 156703
Submitted by:	oleg@mamontov.net
MFC after:	1 week
2019-01-28 02:00:39 +00:00
Eitan Adler
2da6fd55d9 find(1): remove empty else condition
reported by:	brooks
2018-07-25 03:42:07 +00:00
Eitan Adler
b422540a99 find(1): deLINTify 2018-07-01 20:09:52 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Jilles Tjoelker
7a79617cc1 find: Correctly propagate -exec/-execdir ... {} + exit status.
As per POSIX, the -exec ... {} + primary always returns true, but a non-zero
exit status causes find to return a non-zero exit status itself. GNU does
the same, and also for -execdir ... {} +.

It does not make much sense to return false from the primary only when the
child process happens to be run.

The behaviour for -exec/-execdir ... ; remains unchanged: the primary
returns true or false depending on the exit status, and find's exit status
is unaffected.
2014-04-12 22:36:26 +00:00
Jilles Tjoelker
73a0af46b8 find: Treat errno from fts_read() more carefully.
fts_read() leaves errno unchanged on EOF and sets it on error, so set errno
to 0 before calling it. Also, don't trust finish_execplus() to leave errno
unchanged.
2014-04-06 20:04:33 +00:00
Jilles Tjoelker
40072dc2b7 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
2012-07-25 21:59:10 +00:00
Joel Dahl
da52b4caaf 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
2010-12-11 08:32:16 +00:00
Xin LI
3549ef2f2b Revert r207677 which is considered a violation of style(9).
Pointed out by:	bde
Pointy hat to:	delphij
2010-05-06 17:06:36 +00:00
Xin LI
d18129ea1d Move SCCS tags to comments as they were already #if 0'ed. 2010-05-05 21:24:18 +00:00
Xin LI
821df508e8 Revert most part of 200420 as requested, as more review and polish is
needed.
2009-12-13 03:14:06 +00:00
Xin LI
6f2d322192 Remove unneeded header includes from usr.bin/ except contributed code.
Tested with:	make universe
2009-12-11 23:35:38 +00:00
Kirill Ponomarev
22170420ec The last execution of -exec {} + is not done if the -exec primary is
not on the top-level -and sequence, e.g. inside of ! or -or.

Create a separate linked list of all active -exec {} + primaries and
do the last execution for all at termination.

PR:		bin/79263
Submitted by:	Jilles Tjoelker <jilles@stack.nl>
MFC after:	7 days
2006-05-14 20:23:01 +00:00
Oliver Eikemeier
1c8329632e - 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
2004-05-28 17:17:15 +00:00
Mark Murray
ef646f18aa Fix all WARNS. Checked with "make WARNS=9". Remove unused file. 2003-06-14 13:00:21 +00:00
Garrett Wollman
0d3bcc2e80 Make the threatened fts(3) ABI fix. FTSENT now avoids the use of the struct
hack, thereby allowing future extensions to the structure (e.g., for extended
attributes) without rebreaking the ABI.  FTSENT now contains a pointer to the
parent stream, which fts_compar() can then take advantage of, avoiding the
undefined behavior previously warned about.  As a consequence of this change,
the prototype of the comparison function passed to fts_open() has changed
to reflect the required amount of constness for its use.  All callers in the
tree are updated to use the correct prototype.

Comparison functions can now make use of the new parent pointer to access
the new stream-specific private data pointer, which is intended to assist
creation of reentrant library routines which use fts(3) internally.

Not objected to in spirit by: -arch
2002-09-21 01:28:41 +00:00
Tim J. Robbins
5e25d888a8 Support the SysV-style -exec utility args.. {} + function, required by
SUSv3. This is similar to find foo -print0 | xargs -0 utility args.
2002-06-02 12:57:41 +00:00
David E. O'Brien
3077469e0c Fix SCM IDs. 2002-04-01 22:56:56 +00:00
Mark Murray
ecca1f1c0a Remove __P(). 2002-03-20 10:32:05 +00:00
David Malone
e98080b1e6 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.
2002-02-27 17:57:00 +00:00
Poul-Henning Kamp
ea92232a82 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>
2001-05-03 18:05:35 +00:00
Akinori MUSHA
7c1d4b3ae9 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
2001-02-23 16:20:55 +00:00
Ollivier Robert
c76bc8f3bf 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>
2000-06-12 11:12:41 +00:00
Bruce Evans
1b4db9d1fd Fixed my English fixes. 1998-11-29 11:34:30 +00:00
Bruce Evans
ad04e6130e Fixed style bugs and English in previous commit. 1998-11-29 11:11:07 +00:00
Wolfram Schneider
6d0c7e1378 Added a sort option to find(1).
The sort option make it possible to build the locate
database without large (usually 20-100MB) temp files.
1998-11-29 00:54:21 +00:00
Peter Wemm
841484cd42 Merge from Lite2 - use new getvfsbyname() and related changes.
understand whiteouts (FTS_W from fts()).
1997-03-11 13:48:37 +00:00
Rodney W. Grimes
7799f52a32 Remove trailing whitespace. 1995-05-30 06:41:30 +00:00
Guido van Rooij
dcb8def0e7 Fix completely broken find behaviour:
a find -foo -o -bar would behave like find -bar. The same for -a
This broke (among others) ./etc/security.

Obtained from: NetBSD
1995-02-27 20:52:36 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00