History log of /openbsd-current/usr.bin/find/main.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.33 04-Dec-2022 cheloha

userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument. We can
handle this case with the "default" failure case with no loss of
legibility. Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@. With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.32 24-Oct-2021 deraadt

For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef.
ok millert


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.31 03-Jan-2017 tedu

add -delete option which can simplify the common case of wanting to delete
lots of files without the arcane -exec or error prone xargs.
code from freebsd.
ok millert


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.30 18-May-2014 espie

use reallocarray
okay chl@, tedu@


Revision tags: OPENBSD_5_5_BASE
# 1.29 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.28 14-Jun-2011 naddy

exit if there is an unknown option; from FreeBSD
ok millert@


# 1.27 21-Apr-2011 jacekm

find: return exit code 1 if any path could not be traversed
matches posix and the manual, ok millert


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.26 20-Dec-2009 schwarze

find -LH was -L, but must be -H according to POSIX;
patch from Daniel Dickman <didickman at gmail dot com> via tech@,
though i'm updating the manual in a different way;
ok millert@ "looks good" deraadt@


# 1.25 09-Dec-2009 millert

We only need to fchdir(dotfd) for the -exec and -ok primaries so
defer the check for dotfd != -1 until we know we will need it.
Based on a diff from schwarze@


# 1.24 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 10-May-2007 jmc

ftsopen -> fts_open; partly from Alexander Holupirek, documentation/5472
ok simon art


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.22 30-Aug-2005 david

remove -W from synopsis; ok deraadt@ jmc@


# 1.21 15-Jun-2005 millert

no more whiteouts


Revision tags: OPENBSD_3_7_BASE
# 1.20 07-Feb-2005 jaredy

sync and make usage __dead, from Michael Knudsen


# 1.19 15-Sep-2004 deraadt

remove unused variable


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.18 24-Feb-2004 jmc

- remove double spaces in the examples
- `W' before `X'
- sync usage()

ok millert@


# 1.17 26-Sep-2003 tedu

better realloc. ok deraadt@ henning@


Revision tags: OPENBSD_3_4_BASE
# 1.16 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.15 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.14 17-May-2002 millert

The standard way to get info on symlinks is -L, not -h; Peter Werner


Revision tags: OPENBSD_3_1_BASE
# 1.13 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.12 22-Aug-2001 deraadt

expression is optional


# 1.11 22-Aug-2001 hugh

Since we're in pedant mode again, we might as well be thorough. It's
bad form to assume that the absence of an expression will default to
"-print", as one may still encounter versions of find where this is
not the case. The examples given are all careful to use an explicit
"-print", so follow their lead and mark the expression as a required
field even though find will run without one.


# 1.10 22-Aug-2001 heko

o Expression is an optional argument to find(1);
noticed by Brian Poole <raj@cerias.purdue.edu>
o File is not an optional argument
o The section name referenced in beginning of the manual page
is "operators" so don't confuse people by speaking about
"operands"
Ok aaron@


# 1.9 12-Jul-2001 deraadt

first pass at a -Wall cleanup


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.8 17-Mar-1999 espie

Add -W option so -type W gets a chance to work.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.7 17-Jun-1997 millert

Back out last change. Allowing no path to mean "." causes problems
with getopts vs. predicates.


# 1.6 17-Jun-1997 millert

If no paths are specified, use "."


# 1.5 17-Jun-1997 millert

Don't trample argv[], we want ps et al to be able to see args.


Revision tags: OPENBSD_2_1_BASE
# 1.4 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.3 24-Oct-1996 tholo

Respond to SIGINFO; from PR #42


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.32 24-Oct-2021 deraadt

For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef.
ok millert


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.31 03-Jan-2017 tedu

add -delete option which can simplify the common case of wanting to delete
lots of files without the arcane -exec or error prone xargs.
code from freebsd.
ok millert


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.30 18-May-2014 espie

use reallocarray
okay chl@, tedu@


Revision tags: OPENBSD_5_5_BASE
# 1.29 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.28 14-Jun-2011 naddy

exit if there is an unknown option; from FreeBSD
ok millert@


# 1.27 21-Apr-2011 jacekm

find: return exit code 1 if any path could not be traversed
matches posix and the manual, ok millert


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.26 20-Dec-2009 schwarze

find -LH was -L, but must be -H according to POSIX;
patch from Daniel Dickman <didickman at gmail dot com> via tech@,
though i'm updating the manual in a different way;
ok millert@ "looks good" deraadt@


# 1.25 09-Dec-2009 millert

We only need to fchdir(dotfd) for the -exec and -ok primaries so
defer the check for dotfd != -1 until we know we will need it.
Based on a diff from schwarze@


# 1.24 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 10-May-2007 jmc

ftsopen -> fts_open; partly from Alexander Holupirek, documentation/5472
ok simon art


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.22 30-Aug-2005 david

remove -W from synopsis; ok deraadt@ jmc@


# 1.21 15-Jun-2005 millert

no more whiteouts


Revision tags: OPENBSD_3_7_BASE
# 1.20 07-Feb-2005 jaredy

sync and make usage __dead, from Michael Knudsen


# 1.19 15-Sep-2004 deraadt

remove unused variable


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.18 24-Feb-2004 jmc

- remove double spaces in the examples
- `W' before `X'
- sync usage()

ok millert@


# 1.17 26-Sep-2003 tedu

better realloc. ok deraadt@ henning@


Revision tags: OPENBSD_3_4_BASE
# 1.16 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.15 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.14 17-May-2002 millert

The standard way to get info on symlinks is -L, not -h; Peter Werner


Revision tags: OPENBSD_3_1_BASE
# 1.13 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.12 22-Aug-2001 deraadt

expression is optional


# 1.11 22-Aug-2001 hugh

Since we're in pedant mode again, we might as well be thorough. It's
bad form to assume that the absence of an expression will default to
"-print", as one may still encounter versions of find where this is
not the case. The examples given are all careful to use an explicit
"-print", so follow their lead and mark the expression as a required
field even though find will run without one.


# 1.10 22-Aug-2001 heko

o Expression is an optional argument to find(1);
noticed by Brian Poole <raj@cerias.purdue.edu>
o File is not an optional argument
o The section name referenced in beginning of the manual page
is "operators" so don't confuse people by speaking about
"operands"
Ok aaron@


# 1.9 12-Jul-2001 deraadt

first pass at a -Wall cleanup


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.8 17-Mar-1999 espie

Add -W option so -type W gets a chance to work.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.7 17-Jun-1997 millert

Back out last change. Allowing no path to mean "." causes problems
with getopts vs. predicates.


# 1.6 17-Jun-1997 millert

If no paths are specified, use "."


# 1.5 17-Jun-1997 millert

Don't trample argv[], we want ps et al to be able to see args.


Revision tags: OPENBSD_2_1_BASE
# 1.4 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.3 24-Oct-1996 tholo

Respond to SIGINFO; from PR #42


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.31 03-Jan-2017 tedu

add -delete option which can simplify the common case of wanting to delete
lots of files without the arcane -exec or error prone xargs.
code from freebsd.
ok millert


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.30 18-May-2014 espie

use reallocarray
okay chl@, tedu@


Revision tags: OPENBSD_5_5_BASE
# 1.29 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.28 14-Jun-2011 naddy

exit if there is an unknown option; from FreeBSD
ok millert@


# 1.27 21-Apr-2011 jacekm

find: return exit code 1 if any path could not be traversed
matches posix and the manual, ok millert


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.26 20-Dec-2009 schwarze

find -LH was -L, but must be -H according to POSIX;
patch from Daniel Dickman <didickman at gmail dot com> via tech@,
though i'm updating the manual in a different way;
ok millert@ "looks good" deraadt@


# 1.25 09-Dec-2009 millert

We only need to fchdir(dotfd) for the -exec and -ok primaries so
defer the check for dotfd != -1 until we know we will need it.
Based on a diff from schwarze@


# 1.24 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.23 10-May-2007 jmc

ftsopen -> fts_open; partly from Alexander Holupirek, documentation/5472
ok simon art


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.22 30-Aug-2005 david

remove -W from synopsis; ok deraadt@ jmc@


# 1.21 15-Jun-2005 millert

no more whiteouts


Revision tags: OPENBSD_3_7_BASE
# 1.20 07-Feb-2005 jaredy

sync and make usage __dead, from Michael Knudsen


# 1.19 15-Sep-2004 deraadt

remove unused variable


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE
# 1.18 24-Feb-2004 jmc

- remove double spaces in the examples
- `W' before `X'
- sync usage()

ok millert@


# 1.17 26-Sep-2003 tedu

better realloc. ok deraadt@ henning@


Revision tags: OPENBSD_3_4_BASE
# 1.16 10-Jun-2003 deraadt

mostly ansi cleanup; pval ok


# 1.15 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.14 17-May-2002 millert

The standard way to get info on symlinks is -L, not -h; Peter Werner


Revision tags: OPENBSD_3_1_BASE
# 1.13 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.12 22-Aug-2001 deraadt

expression is optional


# 1.11 22-Aug-2001 hugh

Since we're in pedant mode again, we might as well be thorough. It's
bad form to assume that the absence of an expression will default to
"-print", as one may still encounter versions of find where this is
not the case. The examples given are all careful to use an explicit
"-print", so follow their lead and mark the expression as a required
field even though find will run without one.


# 1.10 22-Aug-2001 heko

o Expression is an optional argument to find(1);
noticed by Brian Poole <raj@cerias.purdue.edu>
o File is not an optional argument
o The section name referenced in beginning of the manual page
is "operators" so don't confuse people by speaking about
"operands"
Ok aaron@


# 1.9 12-Jul-2001 deraadt

first pass at a -Wall cleanup


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.8 17-Mar-1999 espie

Add -W option so -type W gets a chance to work.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.7 17-Jun-1997 millert

Back out last change. Allowing no path to mean "." causes problems
with getopts vs. predicates.


# 1.6 17-Jun-1997 millert

If no paths are specified, use "."


# 1.5 17-Jun-1997 millert

Don't trample argv[], we want ps et al to be able to see args.


Revision tags: OPENBSD_2_1_BASE
# 1.4 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.3 24-Oct-1996 tholo

Respond to SIGINFO; from PR #42


Revision tags: OPENBSD_2_0_BASE
# 1.2 26-Jun-1996 deraadt

rcsid


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision