bug-findutils
[Top][All Lists]
Advanced

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

Re: Regression: "find dir/. -type d -empty -delete" claims 'unsuccessful


From: Eric Blake
Subject: Re: Regression: "find dir/. -type d -empty -delete" claims 'unsuccessful', breaking scripts.
Date: Mon, 18 Nov 2013 21:04:58 -0700
User-agent: 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
> extension,
> 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
tree).

> 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
by POSIX.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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