bug-coreutils
[Top][All Lists]
Advanced

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

bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is docu


From: Eric Blake
Subject: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so.
Date: Fri, 07 Sep 2012 17:25:29 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0

On 09/07/2012 03:20 PM, Eric Blake wrote:
> Indeed, reading the original V7 source code from 1979:
> http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/rm.c
> 

> shows that _only_ ".." was special, "." was attempted in-place and
> didn't fail until the unlink(".") after the directory itself had been
> emptied.  It wasn't until later versions of code that "." also became
> special.
> 
> You therefore may have a valid point that POSIX standardized something
> that did not match existing practice at the time, and therefore, it
> would be reasonable to propose a POSIX defect that requires early
> failure on "..", but changes the behavior on "." and "/" to only permit,
> but not require, early failure.  However, I just checked, and the
> prohibition for an early exit on "." has been around since at least
> POSIX 2001, so you are now coming into the game at least 11 years late.

In addition to Alan's argument that 4.3BSD forbade '.' before POSIX
began (and therefore the POSIX folks DID standardize existing practice,
even it wasn't universally common at the time), I find this statement
from POSIX quite informative (line 104265 in POSIX 2008), on why any
proposal to allow 'rm -rf .' to remove non-dot files will probably be
denied:

>> The rm utility is forbidden to remove the names dot and dot-dot in order to 
>> avoid the consequences of inadvertently doing something like:
>> rm −r .*

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]