From 8c0708a329618b20089eb9cedbe06522dd25d9be Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 7 Oct 2015 21:01:47 +0200 Subject: [PATCH] find: support "find . -delete" idiom - do not try rmdir(".") Signed-off-by: Denys Vlasenko --- findutils/find.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/findutils/find.c b/findutils/find.c index f72cad7d1..bd7ccc323 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -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); } -- 2.25.1