bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"find" ends with exit code "0" although exec command returned an error


From: Thomas D.
Subject: "find" ends with exit code "0" although exec command returned an error
Date: Sun, 4 Oct 2015 18:46:49 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

Hi,

for me it looks like "find" returns an invalid exit code when "-exec"
returns an error:

$ mkdir /tmp/find-test
$ touch /tmp/find-test/scripts{1..10}.sh
$ touch /tmp/find-test/text{1..10}.txt
$ find /tmp/find-test -name '*.sh' -exec chmod 755 \; \
  && echo "find succeed" || echo "find failed"

Yes, I am missing the "{}" but that's how I encounter the bug.
Output:

> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> chmod: missing operand after ‘755’
> Try 'chmod --help' for more information.
> find succeed

I expected "find failed" ("find" should have ended with non-zero exit code).

And yes, "chmod 755" returns an error:

$ chmod 755
chmod: missing operand after ‘755’
Try 'chmod --help' for more information.
$ echo $?
1



$ find -version
find (GNU findutils) 4.5.14
Packaged by Gentoo (4.5.14-r1)
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.



-Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]