tech-userlevel archive

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

Re: rmdir -p

On Sun, May 18, 2008 at 09:49:29PM -0400, D'Arcy J.M. Cain wrote:

> Is the following the correct behaviour?
> $ mkdir /tmp/rmdirtest
> $ mkdir /tmp/rmdirtest/x
> $ mkdir /tmp/rmdirtest/x/y
> $ touch /tmp/rmdirtest/z 
> $ rmdir -p /tmp/rmdirtest
> rmdir: /tmp/rmdirtest: Directory not empty

It is.

> There is a package (graphics/librsvg) that is failing to install
> because "rmdir -p" fails trying to remove /usr/pkg/lib.  Not
> surprisingly, that directory is not empty.

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?)

> 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).

- Klaus

Home | Main Index | Thread Index | Old Index