[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regression: "find dir/. -type d -empty -delete" claims 'unsuccessful
Re: Regression: "find dir/. -type d -empty -delete" claims 'unsuccessful', breaking scripts.
Mon, 18 Nov 2013 21:04:58 -0700
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
On 11/18/2013 06:20 PM, Linda Walsh wrote:
>>> However, "find dir/. -type d -empty -delete" works, but
>>> exits with a failure code causing scripts to break.
>> This behavior is required by POSIX. Sorry.
POSIX requires that whatever you pass on the command line ("dir/.") be
passed as the prefix to all paths traversed by find; therefore, find
must traverse "dir/.". POSIX also requires that remove("dir/.") must fail.
> It sure looks like POSIX does NOT require it. "-delete" is a gnu
> so it wouldn't be covered either.
Right, but it makes no sense to handle -delete as though it were
visiting "dir" instead of "dir/.", nor to be inconsistent with what you
would get with the POSIX behavior of "find dir/. | xargs rmdir" (at
least, when there are no directories with space/newline issues in that
> So I ask where you get the idea that it is required by POSIX.
POSIX requires what gets visited, and the GNU extension of -delete
determines the actions attempted on the places visited; since -delete
implies remove(), and since remove("dir/.") is required to fail, it is
the only logical behavior, even if the extension itself is not required
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Description: OpenPGP digital signature