find: support "find . -delete" idiom - do not try rmdir(".")
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 7 Oct 2015 19:01:47 +0000 (21:01 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 7 Oct 2015 19:01:47 +0000 (21:01 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
findutils/find.c

index f72cad7d171acfb7915800b9c859a6df2fc610b4..bd7ccc323f32876805ed7efbbc92bc0b7cf5004f 100644 (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);
        }