find: support "find . -delete" idiom - do not try rmdir(".")

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2015-10-07 21:01:47 +02:00
parent 305958dbd4
commit 8c0708a329

View File

@ -768,7 +768,10 @@ ACTF(delete)
{
int rc;
if (S_ISDIR(statbuf->st_mode)) {
rc = rmdir(fileName);
/* "find . -delete" skips rmdir(".") */
rc = 0;
if (NOT_LONE_CHAR(fileName, '.'))
rc = rmdir(fileName);
} else {
rc = unlink(fileName);
}