[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "find" ends with exit code "0" although exec command returned an err
From: |
Thomas D. |
Subject: |
Re: "find" ends with exit code "0" although exec command returned an error |
Date: |
Mon, 5 Oct 2015 18:50:26 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
Hi,
Bernhard Voelker wrote:
> Thanks for the report, however, although the result may be surprising a bit,
> I think it is mandated by POSIX:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html
>
> If the primary expression is punctuated by a <semicolon>, the utility
> utility_name shall be invoked once for each pathname and the primary
> shall evaluate as true if the utility returns a zero value as exit
> status.
> [...]
>
> If the primary expression is punctuated by a <plus-sign>, [...]. If any
> invocation returns a non-zero value as exit status, the find utility shall
> return a non-zero exit status.
It looks like find's manpage says exactly the opposite:
> -exec command ;
> Execute command; true if 0 status is returned.
>
> [...]
>
> -exec command {} +
> This variant of the -exec action runs the specified command on
> the selected files, but the
> command line is built by appending each selected file name
> at the end; the total number of
> invocations of the command will be much less than the number of
> matched files. The command
> line is built in much the same way that xargs builds its
> command lines. Only one instance of
> `{}' is allowed within the command. The command is executed in
> the starting directory. If
> find encounters an error, this can sometimes cause an immediate
> exit, so some pending commands
> may not be run at all. This variant of -exec always returns
> true.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The reason why I reported this was this text in the manpage
> EXIT STATUS
> find exits with status 0 if all files are processed successfully,
> greater than 0 if errors occur.
> This is deliberately a very broad description, but if the return
> value is non-zero, you should not
> rely on the correctness of the results of find.
So
> find exits with status 0 if all files are processed successfully
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
seems to be wrong, not (only true if you use syntax which doesn't return
always true)?
-Thomas