Subject: Re: bug#25817: Why were Gnu coding standards violated in favor of posix for 'rm -fr .'?: request for reversion of behavior

From: L A Walsh <[email-masked]>
Date: Mon, 20 Feb 2017 13:10:24 -0800

Eric Blake wrote:
> tag 25817 needinfo
> thanks
> 
> On 02/20/2017 01:41 PM, L A Walsh wrote:
> 
>> So... why should 'rm' not be able to start it's deletion
>> from the inside of a directory? (@ "." )?
> 
> Please give more details as to what you think is broken.  Instead of
> describing the problem in vague prose, please show a shell transcript
> that creates a sample directory layout and cd's into the place that you
> want, then attempts the removal that currently fails, as well as
> explaining what you hoped to have happen instead of an error message.
-----
#!/bin/bash
cd /tmp || exit 1
mkdir tstdir || exit 1
mkdir tstdir/usr
mkdir tstdir/var
mount --bind /var /tmp/tstdir/var
mount --bind /usr /tmp/tstdir/usr
mkdir tstdir/{1,2,3}
cd /tmp/tstdir || exit
rm -fr . --one-file-system
---------
Output:
rm: refusing to remove ‘.’ or ‘..’ directory: skipping ‘.’
----
Instead, it should have removed dirs 1,2,3 and not 
not 'var' or 'usr'.

----

rm originally did a depth first traversal and deletion
of files under it.

a few to several years ago a posix change was added to 
change the depth-first traversal and to
inspect local paths before doing the depth-first traversal
of directories like '.' -- and if it found '.' to disallow
any paths below '.' (prior to the depth-first traversal that
used to happen).