GNU bug report logs -
#12339
Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so.
Previous Next
Reported by: Linda Walsh <coreutils <at> tlinx.org>
Date: Mon, 3 Sep 2012 00:34:02 UTC
Severity: normal
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On 09/07/2012 08:54 AM, Linda Walsh wrote:
>
> Using "." to reference content of a dir is standard in other utils -- that
> it doesn't work in 'rm' goes counter to the idea of how rm works -- you
> have
> to remove contents before trying the current dir. It isn't logical to
> think
> that it would try the current dir before anything else -- as it goes
> completely
> contrary to how rm has to work.
At the syscall level, unlink(".") is required to fail. To remove a
directory, you must remove its proper name. You can use
unlink("../child") on systems like Linux that let you remove a directory
that is used as a process' current working directory (on systems like
Windows where this action is forbidden, there's no way to remove the
current working directory). Therefore, at the shell level, POSIX will
let you do 'rm -r ../child'. If you think that POSIX should _also_ let
you attempt 'rm -r .', then propose that as a defect report against
POSIX, rather than griping here.
>
> I say it's a design flaw and inconsistent with other programs.
I would say that it is not a design flaw, but that it is consistent with
the fact that the unlink(".") syscall is required to fail, and that it
is consistent with other Unix implementations. We can agree to disagree
on that point.
--
Eric Blake eblake <at> redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 6 years and 187 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.