GNU bug report logs - #12339
Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so.

Previous Next

Package: coreutils;

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


Message #68 received at 12339 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Bernhard Voelker <mail <at> bernhard-voelker.de>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, Linda Walsh <coreutils <at> tlinx.org>,
	"12339 <at> debbugs.gnu.org" <12339 <at> debbugs.gnu.org>
Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it
	is	documented to do so.
Date: Tue, 04 Sep 2012 17:02:42 +0200
Bernhard Voelker wrote:
> On 09/04/2012 02:55 PM, Jim Meyering wrote:
>> With the following patch, I see new behavior.
>> It's an improvement, but we're still not there:
>>
>>     $ mkdir -p d/e/f; ln -s d s; rm -r s/
>>     rm: cannot remove 's/': Not a directory
>>     [Exit 1]
>>     $ find
>>     .
>>     ./s
>>     ./d
>>
>> Notice how it did traverse s/ into d/, and removed d/e and d/e/f.
>> The only problem is that when it attempted to remove the command-line
>> specified "s/", unlinkat (AT_FDCWD, "s/", AT_REMOVEDIR) failed:
>>
>>     unlinkat(4, "d", 0)                     = 0
>>     unlinkat(5, "f", AT_REMOVEDIR)          = 0
>>     unlinkat(4, "e", AT_REMOVEDIR)          = 0
>>     unlinkat(AT_FDCWD, "s/", AT_REMOVEDIR)  = -1 ENOTDIR (Not a directory)
>>     rm: cannot remove 's/': Not a directory
>>     +++ exited with 1 +++
>>
>> Now, this looks like a problem with unlinkat.
>
> Hmm, what about dereferencing command line symlinks with trailing
> slashes _before_ entering the FTS loop instead?

Thanks, but I'm pretty sure that would be too much work to perform
on any slash-decorated operand.

Besides, I'm not 100% sold on the idea that that final unlinkat
call should be creating a dangling symlink (i.e., by removing
the directory to which "s" points).




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.