GNU bug report logs - #45924
RFE: rmdir -r: recursively remove [empty] directories under the target.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Severity: wishlist; Reported by: L A Walsh <coreutils@HIDDEN>; dated Sun, 17 Jan 2021 00:31:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 45924 <at> debbugs.gnu.org:


Received: (at 45924) by debbugs.gnu.org; 19 Jan 2021 05:18:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 19 00:18:19 2021
Received: from localhost ([127.0.0.1]:49091 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l1jPH-00068q-Au
	for submit <at> debbugs.gnu.org; Tue, 19 Jan 2021 00:18:19 -0500
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:37346)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1l1jPF-00068e-UW
 for 45924 <at> debbugs.gnu.org; Tue, 19 Jan 2021 00:18:18 -0500
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9D26F160122;
 Mon, 18 Jan 2021 21:18:12 -0800 (PST)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id 14XIgZIM4Hha; Mon, 18 Jan 2021 21:18:10 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id E776016012D;
 Mon, 18 Jan 2021 21:18:09 -0800 (PST)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id 4WdV8aX1q1Ab; Mon, 18 Jan 2021 21:18:09 -0800 (PST)
Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com
 [23.243.218.95])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id BA3CD160122;
 Mon, 18 Jan 2021 21:18:09 -0800 (PST)
Subject: Re: bug#45924: RFE: rmdir -r: recursively remove [empty] directories
 under the target.
To: Bernhard Voelker <mail@HIDDEN>,
 L A Walsh <coreutils@HIDDEN>, 45924 <at> debbugs.gnu.org
References: <600384DB.7030708@HIDDEN>
 <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
 <d70da8e3-393b-3d5a-4071-6ae3d91f2746@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Message-ID: <79041ae7-b494-12b2-27d7-cbb34f4de45f@HIDDEN>
Date: Mon, 18 Jan 2021 21:18:09 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.5.0
MIME-Version: 1.0
In-Reply-To: <d70da8e3-393b-3d5a-4071-6ae3d91f2746@HIDDEN>
Content-Type: multipart/mixed; boundary="------------BDD715B4EB1100B83628F76E"
Content-Language: en-US
X-Spam-Score: -2.5 (--)
X-Debbugs-Envelope-To: 45924
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.5 (---)

This is a multi-part message in MIME format.
--------------BDD715B4EB1100B83628F76E
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

On 1/18/21 8:08 AM, Bernhard Voelker wrote:
> On 1/17/21 11:18 PM, Paul Eggert wrote:
>> find DIR -depth -type d -exec rmdir {} +
> 
> find(1) can also find empty directories and delete them:
> 
>    $ find DIR -type d -empty -delete

Thanks, I'd forgotten about that.

I added the attached to the manual, as the point seems worth documenting 
even if we don't change the code.

--------------BDD715B4EB1100B83628F76E
Content-Type: text/x-patch; charset=UTF-8;
 name="0001-doc-rmdir-recursive-substitutes.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0001-doc-rmdir-recursive-substitutes.patch"

From eebed78799a7996dd80b66c493a0fc199705dea3 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@HIDDEN>
Date: Mon, 18 Jan 2021 21:08:39 -0800
Subject: [PATCH] doc: rmdir --recursive substitutes

* doc/coreutils.texi (rmdir invocation): Add note on how to remove
empty subdirectories recursively.
---
 doc/coreutils.texi | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index fe2fc52b7..94c9fbfa5 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -11006,7 +11006,19 @@ Give a diagnostic for each successful removal.
 
 @end table
 
-@xref{rm invocation}, for how to remove non-empty directories (recursively).
+@xref{rm invocation}, for how to remove non-empty directories recursively.
+
+To remove all empty directories under @var{dirname}, including
+directories that become empty because other directories are removed,
+you can use either of the following commands:
+
+@example
+# This uses GNU extensions.
+find @var{dirname} -type d -empty -delete
+
+# This runs on any POSIX platform.
+find @var{dirname} -depth -type d -exec rmdir @{@} +
+@end example
 
 @exitstatus
 
-- 
2.27.0


--------------BDD715B4EB1100B83628F76E--




Information forwarded to bug-coreutils@HIDDEN:
bug#45924; Package coreutils. Full text available.

Message received at 45924 <at> debbugs.gnu.org:


Received: (at 45924) by debbugs.gnu.org; 19 Jan 2021 05:16:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 19 00:16:13 2021
Received: from localhost ([127.0.0.1]:49086 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l1jNE-00054H-Qo
	for submit <at> debbugs.gnu.org; Tue, 19 Jan 2021 00:16:13 -0500
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:37124)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1l1jNC-0004xd-IW
 for 45924 <at> debbugs.gnu.org; Tue, 19 Jan 2021 00:16:11 -0500
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 77B0F160115;
 Mon, 18 Jan 2021 21:16:04 -0800 (PST)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id 56CPagM2_1II; Mon, 18 Jan 2021 21:16:03 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id BE479160122;
 Mon, 18 Jan 2021 21:16:03 -0800 (PST)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id VwUMZ5YF15ua; Mon, 18 Jan 2021 21:16:03 -0800 (PST)
Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com
 [23.243.218.95])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9C097160115;
 Mon, 18 Jan 2021 21:16:03 -0800 (PST)
To: L A Walsh <coreutils@HIDDEN>
References: <600384DB.7030708@HIDDEN>
 <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
 <600568B6.9010904@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Subject: Re: bug#45924: RFE: rmdir -r: recursively remove [empty] directories
 under the target.
Message-ID: <72226d45-9387-beda-5a37-07c7b76e0f7b@HIDDEN>
Date: Mon, 18 Jan 2021 21:16:03 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.5.0
MIME-Version: 1.0
In-Reply-To: <600568B6.9010904@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.5 (--)
X-Debbugs-Envelope-To: 45924
Cc: 45924 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.5 (---)

On 1/18/21 2:53 AM, L A Walsh wrote:
> Except that 'find DIR -depth -type d -exec rmdir {} +'
> is anything but simple and not something anyone outside of
> a minority of *nix users would have a clue about how to create, whereas=
=20
> 'rmdir -r DIR' is both direct and simple and
> more easily understandable

It's not that simple. For example, it's not clear whether rmdir -r=20
should also remove directories containing only empty subdirectories,=20
which is what you asked for. Perhaps some people would want that,=20
perhaps they'd want to remove just empty leaf directories. Or perhaps=20
they'd want rmdir to remove empty subdirectories only if it has=20
permission to do so. Or maybe they'd want to also remove subdirectories=20
whose directory entries are all hidden (start with '.'). Or there are=20
lots of other possible things people could plausibly want.

This is what 'find' is for. If people needed to do something like "rmdir=20
-r" every day then it'd be plausible to add it even though there's a=20
simple substitute. But people don't, so let's stick with what we have.




Information forwarded to bug-coreutils@HIDDEN:
bug#45924; Package coreutils. Full text available.

Message received at 45924 <at> debbugs.gnu.org:


Received: (at 45924) by debbugs.gnu.org; 18 Jan 2021 22:33:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 18 17:33:47 2021
Received: from localhost ([127.0.0.1]:48641 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l1d5n-0001Vg-Bs
	for submit <at> debbugs.gnu.org; Mon, 18 Jan 2021 17:33:47 -0500
Received: from mail-wm1-f42.google.com ([209.85.128.42]:55104)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pixelbeat@HIDDEN>) id 1l1d5l-0001VQ-FY
 for 45924 <at> debbugs.gnu.org; Mon, 18 Jan 2021 17:33:46 -0500
Received: by mail-wm1-f42.google.com with SMTP id i63so14889025wma.4
 for <45924 <at> debbugs.gnu.org>; Mon, 18 Jan 2021 14:33:45 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=Hf5+8RDQ/P9ChliklduibNuKHbGBS4alv0HieO0fm+Y=;
 b=ticu1cquVe44E1sZOXmLanYHF6AVzSjkTWCw/REPfSLkIiW/VIgvBZ5d2lph2/1+aV
 9hwUwsvxySwabVANJexywUurSeMn3ORX5iYnz3xNln6L3w6m0f7tmcyu2HV2g767fPmi
 IA+4TLPVqsAfRVoRMhp7SpbAaRRj7Kkm6XYItFtOYqFkDj1oJVH2Yv3Bh2x3ThguYBnF
 GW4K8rvwM1AycSlSTUwZCBa7Tk9tWbbK3jgZ2e3cc5gyI/Q5TGF0T1WpI95YlSIsMTNE
 hGy1ByxOciA1ezYedIvxieoZ/GwqO8CIr1pLdDjSxY7qbF8Iu+b7LRUnUVJ5ZR3I50fP
 ptLQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=Hf5+8RDQ/P9ChliklduibNuKHbGBS4alv0HieO0fm+Y=;
 b=WCU7mQsacNiPOvU1k/J1opwvAjy6UJ2AJ1Z2iP5R5Zu3d1Yc3vs7iw0T92xZdHIrUy
 QAk8khc1z1YHVItMzVnzvHvACnklxR8tWQ6hgrCdZv6lSBYKLu51h+YYcGEJjszO0qVf
 xxnSbOqRELv9Ho1Z+PAUtjxug/KdMBjC4WhmBZoCvToDUVpug3x3Md1ULkByonvEqKTP
 4a0Qr3wzCIbLM1OPVNC0X7mcSq84QnWicFLX7Ig1wDBCw9sILSnPDflPWTRUXGKvwbvW
 lfuFVBwZN6vtzXVOf4rWxcGKxkXUGe2pbevVjdiB96pSuvybLaEmvWeeDnBnnObRdhvj
 717g==
X-Gm-Message-State: AOAM533eIvNEqO+41FvNDBf1vQecZYcBzJDpvgRHnw/l8GFkeN34n0gF
 jqvXgrq+BZJLSfTgc1Ck6VaiZkgJJgLMSA==
X-Google-Smtp-Source: ABdhPJz/ZA9AOWUaf8MfPS5lM0asZHgVHuJ+/Qr/HwxxbOXfkTFMPwrpcbSx/wUcQzVYqfDs2qSDRA==
X-Received: by 2002:a05:600c:2110:: with SMTP id
 u16mr1274535wml.65.1611009219021; 
 Mon, 18 Jan 2021 14:33:39 -0800 (PST)
Received: from localhost.localdomain
 (86-42-14-227-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.42.14.227])
 by smtp.googlemail.com with UTF8SMTPSA id
 q15sm32078131wrw.75.2021.01.18.14.33.37
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 18 Jan 2021 14:33:38 -0800 (PST)
Subject: Re: bug#45924: RFE: rmdir -r: recursively remove [empty] directories
 under the target.
To: L A Walsh <coreutils@HIDDEN>,
 Bernhard Voelker <mail@HIDDEN>
References: <600384DB.7030708@HIDDEN>
 <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
 <d70da8e3-393b-3d5a-4071-6ae3d91f2746@HIDDEN>
 <6005EC5E.1030206@HIDDEN>
From: =?UTF-8?Q?P=c3=a1draig_Brady?= <P@HIDDEN>
Message-ID: <26e51fcb-92c9-c3c0-e2ca-a4ce437defe1@HIDDEN>
Date: Mon, 18 Jan 2021 22:33:36 +0000
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101
 Thunderbird/84.0
MIME-Version: 1.0
In-Reply-To: <6005EC5E.1030206@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 45924
Cc: Paul Eggert <eggert@HIDDEN>, 45924 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

On 18/01/2021 20:15, L A Walsh wrote:
> 
> 
> On 2021/01/18 08:08, Bernhard Voelker wrote:
> 
>> find(1) can also ... [various examples of find's usefulness elided]
>> Have a nice day,
>> Berny
> ===
> 	As I stated in the original message:
> 
> On 2021/01/16 16:29, L A Walsh wrote:
>> Yes, you could do it some other way, like by using 'find',
>> but since it is about removing directories, having the option
>> under rmdir would seem a natural place to put it.
> 
> Thank you Bernhard, but numerous ways to do it with find don't
> really have the simplicity, of using "remove dir" for its
> "raison d'être":
> 
>    rmdir -r DIR
> 
>    vs. find:
> 
>    find DIR -depth -type d -exec rmdir {} +
> 
> 
> One could also use find to implement recursive file removal instead of
> using 'rm', but that's hardly simple or straightforward as "rm -r"
> either.

`rmdir -r` does have some merit.
However the key thing here is it's an unusual operation.
Also there is a way to achieve it with a single existing command.
Comparing with `rm -r` is not equivalent as that's a vastly more common operation.
Also that has overlaps with other functionality like prompting etc.

So I'd be 70:30 against adding `rmdir -r`

cheers,
Pádraig




Information forwarded to bug-coreutils@HIDDEN:
bug#45924; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Jan 2021 21:18:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 18 16:18:16 2021
Received: from localhost ([127.0.0.1]:48604 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l1buh-0007lv-RH
	for submit <at> debbugs.gnu.org; Mon, 18 Jan 2021 16:18:16 -0500
Received: from lists.gnu.org ([209.51.188.17]:48400)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <Ulf.Zibis@HIDDEN>) id 1l1bik-0007PR-BH
 for submit <at> debbugs.gnu.org; Mon, 18 Jan 2021 16:05:54 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:40220)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Ulf.Zibis@HIDDEN>) id 1l1bii-0003PS-JZ
 for bug-coreutils@HIDDEN; Mon, 18 Jan 2021 16:05:54 -0500
Received: from mout.gmx.net ([212.227.15.18]:47511)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Ulf.Zibis@HIDDEN>) id 1l1bid-0003tm-2i
 for bug-coreutils@HIDDEN; Mon, 18 Jan 2021 16:05:52 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
 s=badeba3b8450; t=1611003944;
 bh=HkO9evpb03Vv+rW2ByfJpl8DEi3cxNNlN4wTkc0c8us=;
 h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To;
 b=Fsr+xIm+k97ZHE4qACLU+/ghMeCBZFm0Q5+WPN44ZDIxek8XRA8q09m5fHWGE6IMz
 RHcq8HyyTBu199pA8eKMTxP2X0JB8RqHHUtoPHusOw3Q+3Mx9Ilo+J1coT0GmoUJQi
 Bq4SLrk2YWQ9MDMAMc1zr2mHjxlOvc5qmEg8XzeQ=
X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c
Received: from [192.168.178.20] ([92.72.0.220]) by mail.gmx.com (mrgmx005
 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MmUHj-1lj9vj3xeT-00iXVl for
 <bug-coreutils@HIDDEN>; Mon, 18 Jan 2021 22:05:43 +0100
Subject: Re: bug#45924: RFE: rmdir -r: recursively remove [empty] directories
 under the target.
To: bug-coreutils@HIDDEN
References: <600384DB.7030708@HIDDEN>
 <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
 <600568B6.9010904@HIDDEN>
From: Ulf Zibis <Ulf.Zibis@HIDDEN>
Message-ID: <a9f044a3-c157-a501-0840-476b842b909b@HIDDEN>
Date: Mon, 18 Jan 2021 22:05:40 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <600568B6.9010904@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: de-DE
X-Provags-ID: V03:K1:D5Xeg+Cfflk6S87c/WADYTtETaVLhMinHPj+UeSTDhYpj1Av04D
 BBT7RaR8v1Hlxorax8VGaONR6Qc0T94w0v1Bu3OojaBa8uF9wQVDpSPJYIxFaqCb+Omno6/
 3DOISfrogzVir7QSbpXwXkPbDjYFSbJnCUXrj2wYUjK5qzoBpgF9wI/lKI7NeiusMAj9I37
 Z/kXR3xqdRGBcpEPCE7OQ==
X-Spam-Flag: NO
X-UI-Out-Filterresults: notjunk:1;V03:K0:dKT8Q463ThE=:i9JchIQXTlxbd/67LhCCKP
 o2vlAoT9xRKm2dfTPZB42eriIwe7JGDmqwL4EHHdyFP1AAukRJ+8eFIXyNUfHD1X0ggj4EF2v
 q8ltblGbiwB0tEtryq7jKF1I8CYirhDNFoJPvkU5hwpRBOSqlS2/rZdPNYcx/aTbBFHQKl7ER
 18lVLNRFeASYCh+OYdqGERRqzp68Uwu3b+9atcDcbDx1SpiCQVZ0X7atY9lL97FYS2fTb0T6b
 LuzCP/q8Guqa6UR6kqPRySnZmSnsv3/8pAbtqMMxIRoaq/MLM9qKUzx6my8dV3rcWZwxrpulb
 8QuWYPY4resOW1BNU9rXLqolCWHxmQb5UI4dd4wR5u7qfCzqAwJx0TZ7XTMNSqCSLNwy929Mg
 vQeZFNrfDRI8audGivBl17F9gDSN7pPDV1IH/s9jwWkj1vDDe7zqCg8fwzw07sfkyaziWcvwA
 dBws2MFCyukHUL3eB3BYWEVA9jGKK8cCHKjF8hlMjeUb2wyYP0gJZ0oXru+DgthYPewN2NO3L
 AtKlX4uwC7vVEM9zftsgi66WxrqaBC/IwSkJY5+GPQ+kZvESOlrAOOYLgiTTgoqeEFxUdPpEC
 114H3sgxJSurk25KBKA8fqZy8Z93tHmN9u1Ig1XEBeQhLgSg9UM9QLIN3ogVpp0b5lBGcejW+
 nAwnvdPXEwRTQUFraCPWdx5Ze/IZIkA1GExEN7v63eDpa+kAo1N5A4YA+/xG4ELy6WhZxeFZ3
 5RJBp2B/KJzefPCL9Asyk7mPedj4e8TJaV8zcJXjgBtgb+iALFeJvW1GWdcmqJ211DOEf4t/a
 H5MFP+XBNPcV9i97H+ptnULwjYh3cDTe8WnjUP4gwlNfparFA0K3eD7QEjDVqBzWVnglDMsLX
 F4xR61r8ZwlD2+gdDKgA==
Received-SPF: pass client-ip=212.227.15.18; envelope-from=Ulf.Zibis@HIDDEN;
 helo=mout.gmx.net
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, NICE_REPLY_A=-0.194,
 RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Mon, 18 Jan 2021 16:18:14 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)


Am 18.01.21 um 11:53 schrieb L A Walsh:
> Except that 'find DIR -depth -type d -exec rmdir {} +'
> is anything but simple and not something anyone outside of
> a minority of *nix users would have a clue about how to create, whereas 'rmdir -r DIR' is both direct and simple and
> more easily understandable by those who know how to remove
> a directory and recursively remove files. Applying the -r
> option of 'rm' and 'rd's focus on dirs seems a natural combination.

+1

Ulf





Information forwarded to bug-coreutils@HIDDEN:
bug#45924; Package coreutils. Full text available.

Message received at 45924 <at> debbugs.gnu.org:


Received: (at 45924) by debbugs.gnu.org; 18 Jan 2021 20:17:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 18 15:17:27 2021
Received: from localhost ([127.0.0.1]:48532 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l1axr-00060L-F3
	for submit <at> debbugs.gnu.org; Mon, 18 Jan 2021 15:17:27 -0500
Received: from ishtar.tlinx.org ([173.164.175.65]:54804
 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <coreutils@HIDDEN>) id 1l1axp-00060C-My
 for 45924 <at> debbugs.gnu.org; Mon, 18 Jan 2021 15:17:26 -0500
Received: from [192.168.3.12] (Athenae [192.168.3.12])
 by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
 10IKHHTO095073; Mon, 18 Jan 2021 12:17:19 -0800
Message-ID: <6005EC5E.1030206@HIDDEN>
Date: Mon, 18 Jan 2021 12:15:26 -0800
From: L A Walsh <coreutils@HIDDEN>
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
To: Bernhard Voelker <mail@HIDDEN>
Subject: Re: bug#45924: RFE: rmdir -r: recursively remove [empty] directories
 under the target.
References: <600384DB.7030708@HIDDEN>
 <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
 <d70da8e3-393b-3d5a-4071-6ae3d91f2746@HIDDEN>
In-Reply-To: <d70da8e3-393b-3d5a-4071-6ae3d91f2746@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 45924
Cc: Paul Eggert <eggert@HIDDEN>, 45924 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



On 2021/01/18 08:08, Bernhard Voelker wrote:

> find(1) can also ... [various examples of find's usefulness elided]
> Have a nice day,
> Berny
=3D=3D=3D
	As I stated in the original message:

On 2021/01/16 16:29, L A Walsh wrote:
> Yes, you could do it some other way, like by using 'find',
> but since it is about removing directories, having the option
> under rmdir would seem a natural place to put it.

Thank you Bernhard, but numerous ways to do it with find don't=20
really have the simplicity, of using "remove dir" for its
"raison d'=C3=AAtre":

  rmdir -r DIR

  vs. find:

  find DIR -depth -type d -exec rmdir {} +


One could also use find to implement recursive file removal instead of
using 'rm', but that's hardly simple or straightforward as "rm -r"
either.









Information forwarded to bug-coreutils@HIDDEN:
bug#45924; Package coreutils. Full text available.

Message received at 45924 <at> debbugs.gnu.org:


Received: (at 45924) by debbugs.gnu.org; 18 Jan 2021 16:09:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 18 11:09:10 2021
Received: from localhost ([127.0.0.1]:47990 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l1X5Z-0003rS-Uq
	for submit <at> debbugs.gnu.org; Mon, 18 Jan 2021 11:09:10 -0500
Received: from mout.kundenserver.de ([217.72.192.75]:40243)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1l1X5Y-0003rE-Ap
 for 45924 <at> debbugs.gnu.org; Mon, 18 Jan 2021 11:09:08 -0500
Received: from [192.168.101.10] ([91.1.218.73]) by mrelayeu.kundenserver.de
 (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id
 1MUokB-1lRgxB2Wf3-00Qn5M; Mon, 18 Jan 2021 17:08:52 +0100
Subject: Re: bug#45924: RFE: rmdir -r: recursively remove [empty] directories
 under the target.
To: Paul Eggert <eggert@HIDDEN>, L A Walsh <coreutils@HIDDEN>,
 45924 <at> debbugs.gnu.org
References: <600384DB.7030708@HIDDEN>
 <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
From: Bernhard Voelker <mail@HIDDEN>
Message-ID: <d70da8e3-393b-3d5a-4071-6ae3d91f2746@HIDDEN>
Date: Mon, 18 Jan 2021 17:08:51 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.6.0
MIME-Version: 1.0
In-Reply-To: <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Provags-ID: V03:K1:7bsTYRbefIeNjv/UkaLBNAtphW7Zwk6YOqGh+FZlVSmHBmWH1wM
 LtHPVtaER7vE9WwlgB8fOs3wjcmlHKTpHuQOXn93wdZiNbZSMs0Ew65Qr4a2xBjWZ09x1Aa
 hdZ9I5PfT2/gOg9STp9kCP0xq3bf82lvwbgvDJqEZpGy0Zv53ccyoNRwIp+pHCAJ0PUcN50
 REB3m+cvT5KIMaKHMwR5w==
X-Spam-Flag: NO
X-UI-Out-Filterresults: notjunk:1;V03:K0:EojnvtJltk0=:/uGrm//H9YtWEDUVBXphzC
 08bv6YH2ka2AtDcLSVc+HpYEy/ktaXCZgXLcauVNDGxgttk8ABvEWc9c4TPY+Zw+ONUXRveyU
 QSEQuV+CHWJttw9gEFgiPowNH4dX8aABdxZydzdmNvW+eMKxAg9jG26M1lXCWlISvug1kNOPh
 PrUgGSSZjb2wJcBEPYUKeguuSeBVu1g6A29+Ik5cjyM1t7PIqhZarVHNaJgbonMqyQikm4tN5
 U1njpKjVzicokQIng712TGboNMSf0XE2xs/oVaxRztOQ6ihQZ8Eo34F7OxfUwV/KLKJUIuVQD
 KOztZVPv/TgEDIHlFiXF0E/KHISnEx6crDePAMuzOvnHqBSlcBt2FPrhfC4YpSuU90lACNhHG
 wswvmVS4Hz3dOCsJX6hbdzoHp9yCEcexf4+t/3E19nxxcL2e/Wp5xFs50SWzc0DuCdZEAlN+i
 ImhRgbgW4Q==
X-Spam-Score: -0.2 (/)
X-Debbugs-Envelope-To: 45924
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.2 (-)

On 1/17/21 11:18 PM, Paul Eggert wrote:
> find DIR -depth -type d -exec rmdir {} +

find(1) can also find empty directories and delete them:

  $ find DIR -type d -empty -delete

FWIW: -delete implies -depth.

If one wants to see what empty directories have been found (and get deleted),
just put a -print in there:

  $ find DIR -type d -empty -print -delete

The above works with GNU find (as both -empty and -delete are GNU extensions).

Have a nice day,
Berny




Information forwarded to bug-coreutils@HIDDEN:
bug#45924; Package coreutils. Full text available.

Message received at 45924 <at> debbugs.gnu.org:


Received: (at 45924) by debbugs.gnu.org; 18 Jan 2021 10:54:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 18 05:54:57 2021
Received: from localhost ([127.0.0.1]:46457 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l1SBV-0006Cl-5h
	for submit <at> debbugs.gnu.org; Mon, 18 Jan 2021 05:54:57 -0500
Received: from ishtar.tlinx.org ([173.164.175.65]:34948
 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <coreutils@HIDDEN>) id 1l1SBS-0006Cb-BU
 for 45924 <at> debbugs.gnu.org; Mon, 18 Jan 2021 05:54:55 -0500
Received: from [192.168.3.12] (Athenae [192.168.3.12])
 by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
 10IAsiju047437; Mon, 18 Jan 2021 02:54:46 -0800
Message-ID: <600568B6.9010904@HIDDEN>
Date: Mon, 18 Jan 2021 02:53:42 -0800
From: L A Walsh <coreutils@HIDDEN>
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
To: Paul Eggert <eggert@HIDDEN>
Subject: Re: bug#45924: RFE: rmdir -r: recursively remove [empty] directories
 under the target.
References: <600384DB.7030708@HIDDEN>
 <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
In-Reply-To: <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 45924
Cc: 45924 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Except that 'find DIR -depth -type d -exec rmdir {} +'
is anything but simple and not something anyone outside of
a minority of *nix users would have a clue about how to 
create, whereas 'rmdir -r DIR' is both direct and simple and
more easily understandable by those who know how to remove
a directory and recursively remove files. Applying the -r
option of 'rm' and 'rd's focus on dirs seems a natural 
combination.


Gnu authors seem to pride themselves on their technical and
programming expertise (and not necessarily, w/o reason); but like
many high-level engineers, seem to lose touch with the concept of
'user-friendly' and often, it seems, tend toward the idea that the
users can and should adapt to the program(s) for the sake of
the programs (and engineers).  This is in contrast to the idea
of computers (and programs) being designed as tools to aid, assist,
simplify and empower those who use such tools.

 

On 2021/01/17 14:18, Paul Eggert wrote:
> On 1/16/21 4:29 PM, L A Walsh wrote:
>> Yes, you could do it some other way, like by using 'find'
> 
> That's what I'd do, yes. 'find DIR -depth -type d -exec rmdir {} +'. I 
> doubt whether it's worth hacking on this at the C level (complicating 
> the documentation too) when there's such a simple and portable way to do 
> this unusual task already.




Information forwarded to bug-coreutils@HIDDEN:
bug#45924; Package coreutils. Full text available.

Message received at 45924 <at> debbugs.gnu.org:


Received: (at 45924) by debbugs.gnu.org; 17 Jan 2021 22:19:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 17 17:19:11 2021
Received: from localhost ([127.0.0.1]:45866 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l1GO4-0000hY-BO
	for submit <at> debbugs.gnu.org; Sun, 17 Jan 2021 17:19:11 -0500
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:37638)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1l1GO2-0000h4-CH
 for 45924 <at> debbugs.gnu.org; Sun, 17 Jan 2021 17:19:07 -0500
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0C198160110;
 Sun, 17 Jan 2021 14:19:00 -0800 (PST)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id qthwb0kOecQg; Sun, 17 Jan 2021 14:18:59 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 615A8160117;
 Sun, 17 Jan 2021 14:18:59 -0800 (PST)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id UvAP1LZ-m4hL; Sun, 17 Jan 2021 14:18:59 -0800 (PST)
Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com
 [23.243.218.95])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 3D7CA160110;
 Sun, 17 Jan 2021 14:18:59 -0800 (PST)
To: L A Walsh <coreutils@HIDDEN>, 45924 <at> debbugs.gnu.org
References: <600384DB.7030708@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Subject: Re: bug#45924: RFE: rmdir -r: recursively remove [empty] directories
 under the target.
Message-ID: <83575022-8da6-5dcd-0386-ddaea5a45cf5@HIDDEN>
Date: Sun, 17 Jan 2021 14:18:58 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.5.0
MIME-Version: 1.0
In-Reply-To: <600384DB.7030708@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.6 (--)
X-Debbugs-Envelope-To: 45924
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.5 (---)

On 1/16/21 4:29 PM, L A Walsh wrote:
> Yes, you could do it some other way, like by using 'find'

That's what I'd do, yes. 'find DIR -depth -type d -exec rmdir {} +'. I=20
doubt whether it's worth hacking on this at the C level (complicating=20
the documentation too) when there's such a simple and portable way to do=20
this unusual task already.




Information forwarded to bug-coreutils@HIDDEN:
bug#45924; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Jan 2021 00:30:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 16 19:30:48 2021
Received: from localhost ([127.0.0.1]:44352 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l0vxw-0004qQ-8w
	for submit <at> debbugs.gnu.org; Sat, 16 Jan 2021 19:30:48 -0500
Received: from lists.gnu.org ([209.51.188.17]:38122)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <coreutils@HIDDEN>) id 1l0vxu-0004qJ-UQ
 for submit <at> debbugs.gnu.org; Sat, 16 Jan 2021 19:30:48 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:44902)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <coreutils@HIDDEN>)
 id 1l0vxu-0002Ex-KS
 for bug-coreutils@HIDDEN; Sat, 16 Jan 2021 19:30:46 -0500
Received: from ishtar.tlinx.org ([173.164.175.65]:55312
 helo=Ishtar.sc.tlinx.org)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <coreutils@HIDDEN>)
 id 1l0vxr-00041d-K9
 for bug-coreutils@HIDDEN; Sat, 16 Jan 2021 19:30:46 -0500
Received: from [192.168.3.12] (Athenae [192.168.3.12])
 by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
 10H0UcJp025944
 for <bug-coreutils@HIDDEN>; Sat, 16 Jan 2021 16:30:40 -0800
Message-ID: <600384DB.7030708@HIDDEN>
Date: Sat, 16 Jan 2021 16:29:15 -0800
From: L A Walsh <coreutils@HIDDEN>
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
To: Coreutils <bug-coreutils@HIDDEN>
Subject: RFE: rmdir -r: recursively remove [empty] directories under the
 target.
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Received-SPF: pass client-ip=173.164.175.65; envelope-from=coreutils@HIDDEN;
 helo=Ishtar.sc.tlinx.org
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Every once in a while, I want to remove what I believe to be
an empty directory tree, safely.

I wondered, why not have rmdir have a recursive option
that would remove all directories under a given directory,
presuming they were empty.  That way I can try to remove
the tree, removing what it can, and only failing if it
ran into a file that prevented the removal.

I'd _at least_, have it do a depth-first removal and halt
with a ENOTEMPTY status if an rmdir failed to remove a
directory due to it not being empty.

So for dirs one,two,three + file dir 'two' next to three:

one-+two-+three
         |-file

rmdir -r one  would first remove
one/two/three,
then fail removing one/two because 'two wasn't empty'.

--- probably, I think adding a mode like "--failearly"
should also be available to have rmdir fail on the recursive
descent if it encountered non-dir while descending.

Yes, you could do it some other way, like by using 'find',
but since it is about removing directories, having the option
under rmdir would seem a natural place to put it.

Useful?










Acknowledgement sent to L A Walsh <coreutils@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#45924; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 21 Feb 2022 10:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.