bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45924: RFE: rmdir -r: recursively remove [empty] directories under t


From: L A Walsh
Subject: bug#45924: RFE: rmdir -r: recursively remove [empty] directories under the target.
Date: Sat, 16 Jan 2021 16:29:15 -0800
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)

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?











reply via email to

[Prev in Thread] Current Thread [Next in Thread]