"find" command exit status (QNX 6.3.0)

The “find” command in 6.3.0 seems to always exit with status 0. If I
enter “find ./ -name junk; echo $?” on a 6.2 machine, I get “1”, but on
a 6.3 machine I get “0” (of course there is no file named “junk” on
either system). What am I missing?


Murf

John Murphy wrote:

The “find” command in 6.3.0 seems to always exit with status 0. If I
enter “find ./ -name junk; echo $?” on a 6.2 machine, I get “1”, but on
a 6.3 machine I get “0” (of course there is no file named “junk” on
either system). What am I missing?

I think this was a bug in 6.2 (ref 18763). The POSIX definition for the
find exit status is “0: All path operands were traversed succesfully”.
In other words, it is a reflection of the paths (in your example “./”)
as opposed to any primary expressions (in your case “-name junk”).

Interesting! Your docs, as I read them, say 0 indicates “At least one file
was found that matched the search criteria”, while >0 indicates “An error, or
no files found matching the search criteria.” By that standard, and assuming
that “the search criteria” means “ALL the search criteria”, 6.2 sound like
the one that’s OK - maybe the docs should give an example.

Thanks for the clarification!

Murf

John Garvey wrote:

John Murphy wrote:
The “find” command in 6.3.0 seems to always exit with status 0. If I
enter “find ./ -name junk; echo $?” on a 6.2 machine, I get “1”, but on
a 6.3 machine I get “0” (of course there is no file named “junk” on
either system). What am I missing?

I think this was a bug in 6.2 (ref 18763). The POSIX definition for the
find exit status is “0: All path operands were traversed succesfully”.
In other words, it is a reflection of the paths (in your example “./”)
as opposed to any primary expressions (in your case “-name junk”).

John Murphy wrote:

Interesting! Your docs, as I read them, say 0 indicates “At least one file
was found that matched the search criteria”, while >0 indicates “An error, or
no files found matching the search criteria.” By that standard, and assuming
that “the search criteria” means “ALL the search criteria”, 6.2 sound like
the one that’s OK - maybe the docs should give an example.

I guess 6.2 was self-consistent: the behaviour matched the docs; but it
wasn’t POSIX. The behaviour has been aligned, but I guess the docs
missed out. I’ve aimed our docs guy at this (find exit status) and also
the out-of-date usemsg content (from another thread); thanks for
pointing this out …

On Fri, 20 Aug 2004 09:26:50 -0500, John Murphy wrote:

The “find” command in 6.3.0 seems to always exit with status 0. If I
enter “find ./ -name junk; echo $?” on a 6.2 machine, I get “1”, but on
a 6.3 machine I get “0” (of course there is no file named “junk” on
either system). What am I missing?


Murf

And presumably the original behaviour could be restored under 6.3 by
something like…

$ find ./ -name junk -o -error; echo $?

Although this doesn’t seem to work on 6.2.1 and I don’t have a 6.3 system
handy to verify this on…

Rob Rutherford
Ruzz Technology

Robert Rutherford wrote:

On Fri, 20 Aug 2004 09:26:50 -0500, John Murphy wrote:

The “find” command in 6.3.0 seems to always exit with status 0. If I
enter “find ./ -name junk; echo $?” on a 6.2 machine, I get “1”, but on
a 6.3 machine I get “0” (of course there is no file named “junk” on
either system). What am I missing?


Murf

And presumably the original behaviour could be restored under 6.3 by
something like…

$ find ./ -name junk -o -error; echo $?

Interesting idea, but that seems to ALWAYS force a nonzero exit status.

Murf

Although this doesn’t seem to work on 6.2.1 and I don’t have a 6.3 system
handy to verify this on…

Rob Rutherford
Ruzz Technology