"find" command exit status wrong?

The exit status for “find” command is defined as

0 All path operands were traversed successfully.

0 An error occurred.

in POSIX and QNX manual,
but whatif there were NO matches, nothing was traversed?

Test:
$ mkdir freshdir
$ cd freshdir
$ find . -type f # no matches
$ echo $?


The Solaris find and GNU find returns 0 (“success”).
QNX find returns 1 (“error”).

This is a boundary condition not clearly specified in POSIX,
but if there’s no problem, it’s better that
QNX find returns 0 too for this.

Actual problem: GNU automake testsuite fails because of this.
I’d like to have QSSL comments before issuing bugreport to automake.
(They may say “QNX sux” without a good investigation report)

kabe

I’d say that our implementation doesn’t conform to the spec. BTW, the QNX
docs appears to agree with what the utility does, but the POSIX spec
doesn’t. Too bad, since this behavior can’t be reproduced with the available
set of primitives in a find expression. If we change it we should probably
add add a primitive that would cause find to use the current behavior
(acting similar to -xdev in that it would take effect on startup when it is
parsed, rather than when the expression is evaluated during the traversal of
the paths).

For the time being, you could try find … -true -o
Your expression will need a -print or something similar to stop the
auto -print for the expression as a whole.

I’ll enter a PR against the find utility on this.

  • Eric

<kabe@sra-tohoku.co.jp> wrote in message news:bvvu43$2l2$1@inn.qnx.com

The exit status for “find” command is defined as

0 All path operands were traversed successfully.
0 An error occurred.

in POSIX and QNX manual,
but whatif there were NO matches, nothing was traversed?

Test:
$ mkdir freshdir
$ cd freshdir
$ find . -type f # no matches
$ echo $?


The Solaris find and GNU find returns 0 (“success”).
QNX find returns 1 (“error”).

This is a boundary condition not clearly specified in POSIX,
but if there’s no problem, it’s better that
QNX find returns 0 too for this.

Actual problem: GNU automake testsuite fails because of this.
I’d like to have QSSL comments before issuing bugreport to automake.
(They may say “QNX sux” without a good investigation report)

kabe

eric@qnx.com sed in <c00rtp$q02$1@inn.qnx.com>:

I’ll enter a PR against the find utility on this.

Thanks. Meanwhile I could get around the “feature”
by fixing the automake scripts (which GNU people may frown upon)

kabe