rm -rf . does not delete content of the dir

Bug #1297147 reported by Hans Ginzel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
New
Undecided
Unassigned

Bug Description

Command rm -rf .
writes:
rm: cannot remove directory: ‘.’

That is OK. But it does not delete the content of the dir ‘.’. Command rm -rf * is not the alternative because
1) it does not include hidden files/directories,
2) number of files could exceed max command line length.

Alternative is: find . -delete, but I vote for repairing the rm command.

Commands to reproduce:
mkdir tmp_rm_test
cd tmp_rm_test
echo a>.a
mkdir b
ls -A
rm -rf .
ls -A
find . -delete
ls -A
cd ..
rmdir tmp_rm_test

ProblemType: Bug
DistroRelease: Ubuntu 13.10
Package: coreutils 8.20-3ubuntu5
ProcVersionSignature: Ubuntu 3.11.0-18.12-lowlatency 3.11.10.4
Uname: Linux 3.11.0-18-lowlatency i686
ApportVersion: 2.12.5-0ubuntu2.2
Architecture: i386
Date: Tue Mar 25 09:57:39 2014
EcryptfsInUse: Yes
MarkForUpload: True
SourcePackage: coreutils
UpgradeStatus: Upgraded to saucy on 2013-10-24 (152 days ago)

Revision history for this message
Hans Ginzel (hans-matfyz) wrote :
Revision history for this message
Hans Ginzel (hans-matfyz) wrote :

This bug is also in POSIX:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html

If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component) or if an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands.

But the paragraph is not considering -r and -f options.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.