bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is docu
From:
Linda Walsh
Subject:
bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so.
Date:
Mon, 03 Sep 2012 07:35:02 -0700
User-agent:
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666
Jim Meyering wrote:
I see from your mention of "." below that you are objecting
to rm's refusal to remove "." or "..".
---
I see from your response that you misunderstood
what I wrote. There was no mention of "..". I wouldn't expect
"rm" to crawl backward out of a "rm" in any even -- error message or
not.
---
But you fail to follow the earlier stated POSIX
requirement:
..
" If this fails for any reason, rm shall write a diagnostic message to standard
error, do nothing more with the current file, and go on to any remaining files."
Specifically, in regards to a failure to remove a directory:
For each entry contained in file, other than dot or dot-dot, the four steps
listed here (1 to 4) shall be taken with the entry as if it were a file operand.
The rm utility shall not traverse directories by following symbolic links into
other parts of the hierarchy, but shall remove the links themselves."
So for each entry in ".", except for . and .., rm is to traverse and remove them
even after encountering an error -- which normally, it would only encounter at
the
end of removing all files in the directory.
Sides -- it normally does depth-first traversal --- since you can't delete
a dir with contents still in it -- so why different for '.'?
Safety, I suspect. "." and ".." may not mean anything to a novice.
----
Again, ".." isn't the issue anymore than it should be skipped.
What is at issue is the order of deletion (depth first), and
it's not continuing to delete the other entires in the 'file' other
than "." and ".." after encountering any errors (including a rejection
to delete . and ..).
So the error message is fine.
But not deleting everything else in the dir isn't (at least
judging from the POSIX doc you pointed me at... -- Thanks for
the reference!