tech-userlevel archive

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

Re: rmdir -p

On Mon, 19 May 2008 10:13:19 +0200
Klaus Klein <> wrote:
> rmdir(1) states for -p that the argument is "a pathname of which all
> components will be removed"; that is "rmdir -p /usr/pkg/lib" is
> equivalent to:
>       rmdir /usr/pkg/lib &&
>       rmdir /usr/pkg &&
>       rmdir /usr
> as opposed to the rm -r /usr/pkg/lib that seems to be intended.
> (Why would a package ever want to perform the former?)

To prune empty directories.

> > It seems to me that "rmdir
> > -p" should silently ignore directories that it cannot remove.
> Utilities should not silently ignore domain errors of their
> arguments. rmdir(1) is quite clear on operating on empty
> directories only (or otherwise empty components, for -p).

But is it an error?  If the intention is to remove a directory and any
otherwise empty parents and that's what it does, why throw an error?

Is -p ever useful for absolute paths with this behaviour?  I would
certainly not consider it an error that it failed to remove /usr in the
above example.  I like my /usr.

D'Arcy J.M. Cain <>

Home | Main Index | Thread Index | Old Index