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?