bug-coreutils
[Top][All Lists]
Advanced

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

bug#20835: rmdir foo/. fails


From: Stephane Chazelas
Subject: bug#20835: rmdir foo/. fails
Date: Wed, 17 Jun 2015 12:08:07 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-06-17 10:24:13 +0000, Ed Avis:
> % mkdir foo
> % rmdir foo/.
> rmdir: failed to remove ‘foo/.’: Invalid argument
> % rmdir --version
> rmdir (GNU coreutils) 8.23
> Copyright (C) 2014 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> 
> Written by David MacKenzie.
> 
> 
> I suggest that 'rmdir foo/.' should be equivalent to 'rmdir foo'.
> Strangely, 'rmdir foo/..' does work as expected (that is, it fails with
> 'Directory not empty').
> 
> Note that Emacs command completion (in shell-mode) will complete foo to foo/.
[...]

rmdir(1) is an interface to the rmdir(2) system call. It's that
system call that returns with EINVAL or ENOTEMPTY on your
system.

So you'd want to report it to Linux instead, not coreutils.
I'd doubt the Linux developers would be willing to change the
behaviour though. foo/. is a directory entry in foo that is a
hardlink to foo.

Note that Linux at least reports ENOTEMPTY on .. even when it's
empty.

~$ mkdir -p D/D
~$ cd D/D
~/D/D$ rmdir ../D
~/D/D$ rmdir ..
rmdir: failed to remove ‘..’: Directory not empty
~/D/D$ rmdir ~/D
~/D/D$

That could be seen as a POSIX requirement:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/rmdir.html

     [EEXIST] or [ENOTEMPTY]
             The path argument names a directory that is not an
             empty directory, or there are hard links to the
             directory other than dot or a single entry
             in dot-dot.

(though by that text, rmdir . should probably also return ENOTEMPTY)

Solaris 10 behaves like linux (EINVAL for ".", EEXIST for "..").
The rmdir utility there is more explicit:

$ rmdir D/. D/..
rmdir: directory "D/.": Can't remove current directory or ..
rmdir: directory "D/..": Directory not empty

FreeBSD returns EINVAL for both . and ..

-- 
Stephane






reply via email to

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