Hi!  As the author of a find-compatible tool, whenever I find another
find implementation I run my testsuite against it to see if I find any
bugs in either one.  sbase/find helped me identify many places in my
POSIX tests that use extensions to POSIX when they shouldn't, so
thanks!  Here's the bugs that I found in sbase/find:

- Errors reported for broken symlinks in -L/-H modes -

$ mkdir foo
$ ln -s nowhere foo/broken
$ touch foo/bar
$ ln -s bar/baz foo/notdir
$ ./find -L foo
foo
foo/bar
./find: failed to stat foo/broken: No such file or directory
./find: failed to stat foo/notdir: Not a directory
$ ./find -H foo/broken
./find: failed to stat foo/broken: No such file or directory
$ ./find -H foo/notdir
./find: failed to stat foo/notdir: Not a directory

For -H/-L, POSIX says
(http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html)

> If the referenced file does not exist, the file information and type shall be 
> for the link itself.

- Names longer than PATH_MAX are broken -

POSIX says

> The find utility shall be able to descend to arbitrary depths in a file 
> hierarchy and shall not fail due to path length limitations (unless a path 
> operand specified by the application exceeds {PATH_MAX} requirements).

but:

$ name="0123456789ABCDEF"
$ name="${name}${name}${name}${name}"
$ name="${name}${name}${name}${name}"
$ name="${name:0:255}"
$ (mkdir deep && cd deep && for i in {1..17}; do mkdir $name && cd $name; done)
$ ./find deep
...
./find: failed to stat deep/...ABCDE: File name too long

Despite that, it exits successfully, which is probably also a bug.

- find -newer follows symbolic links -

$ mkdir foo
$ touch foo/bar
$ ln -s bar foo/baz
$ touch foo/qux
$ ./find foo -newer foo/baz
foo
foo/baz
foo/qux

foo/baz is not newer than itself though.

- find -perm doesn't support X -

$ ./find . -perm a+rX,u+w
./find: a+rX,u+w: invalid mode

About the mode format for -perm, POSIX says

> It shall be identical in format to the symbolic_mode operand described in 
> chmod

chmod supports X, so find should too.

If you want to run these tests yourself, clone
https://github.com/tavianator/bfs and run

$ ./tests.sh --bfs=path/to/sbase/find --posix

--
Tavian Barnes

Reply via email to