Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Apr 1995 18:22:22 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-current@FreeBSD.org, taob@gate.sinica.edu.tw
Subject:   Re: Behaviour of rm/rmdir
Message-ID:  <199504180822.SAA11255@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>    This is something that has been bothering me for years... dunno
>why I suddenly decide to bring it up now.  ;-)  Why do "rm -r[f]" and
>"rmdir" complain about removing an empty directory if you append a
>slash to the name?  I mean, this looks pretty ridiculous to me:

>% du testdir
>2371    testdir
>% rm -rf testdir/
>rm: testdir/: Is a directory     <--- tell me something I don't know...
>% rmdir testdir/
>rmdir: testdir/: Is a directory  <--- argh!!!

>    It isn't a big deal to leave off the trailing slash, but filename
>completion in tcsh and bash both append it.  Is this just a 4.4BSD
>thing?  I checked around on our IRIX, SunOS, Solaris and AIX machines
>and none exhibit this behaviour.  BSD/OS 2.0 rm/rmdir behave this way
>too.  Bug or feature?

It is apprently a BSD thing.  It was in FreeBSD-1.1.5.  I fixed it
there, and have updated the changes to FreeBSD-2.1-Development
except for one detail that causes an infinite loop for "testdir/"
when testdir is a symlink (perhaps to a directory).  POSIX requires
trailing slashes to work right and the other OS's are probably more
POSIXish than FreeBSD.  Some versions of `rm' and `rmdir' mask the
bug by gratuitously stripping trailing slashes.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199504180822.SAA11255>