bin/166554: find -delete is silent when failing to rmdir
nonempty directories
Matthew Story
matthewstory at gmail.com
Sun Apr 1 18:20:16 UTC 2012
The following reply was made to PR bin/166554; it has been noted by GNATS.
From: Matthew Story <matthewstory at gmail.com>
To: Richard Kettlewell <rjk at greenend.org.uk>
Cc: freebsd-gnats-submit at freebsd.org
Subject: Re: bin/166554: find -delete is silent when failing to rmdir nonempty directories
Date: Sun, 1 Apr 2012 14:10:04 -0400
--bcaec51d21a4a5912104bca1fbed
Content-Type: text/plain; charset=ISO-8859-1
On Sun, Apr 1, 2012 at 5:29 AM, Richard Kettlewell <rjk at greenend.org.uk> wrote:
> find -delete is documented as removing files and/or directories. However since it uses rmdir() it cannot remove nonempty directories. This is fine, but it suppresses the error message in this case. This leads to considerable user confusion.
>
> I suggest that:
>
> 1. The limitation that it can only remove nonempty directories be documented.
> 2. The error message not be suppressed (i.e. that the ENOTEMPTY test be removed).
>
> GNU find -delete does produce an error message in this case.
I agree with this assessment, patch attached for consideration.
Following the patch:
$ # old behavior
$ mkdir -p foo/bar/baz
$ find ./foo -depth 1 -delete
$ find ./foo -depth 1
./foo/bar
$ # new behavior
$ mkdir -p foo/bar/baz
$ find ./foo -depth 1 -delete
find: -delete: rmdir(./foo/bar): Directory not empty
$ find ./foo -depth 1
./foo/bar
>
> -delete seems to be an extension compare to SUS find, so I don't believe there are any standards-compliance questions here.
POSIX 2008 does not define any -delete primary, so there are no
standards-compliance questions.
Patch is also available via HTTP here:
http://axe0.blackskyresearch.net/patches/matt/freebsd.PR166554.patch.txt
--
regards,
matt
--bcaec51d21a4a5912104bca1fbed
Content-Type: text/plain; charset=US-ASCII; name="freebsd.PR166554.patch.txt"
Content-Disposition: attachment; filename="freebsd.PR166554.patch.txt"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_h0iem7k00
SW5kZXg6IGZpbmQuMQo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLS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