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
signature.asc
Description: OpenPGP digital signature