GNU bug report logs - #21051
direct/file deletion

Previous Next

Package: coreutils;

Reported by: Lee Sung <lsung <at> juniper.net>

Date: Mon, 13 Jul 2015 21:44:02 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21051 in the body.
You can then email your comments to 21051 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#21051; Package coreutils. (Mon, 13 Jul 2015 21:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lee Sung <lsung <at> juniper.net>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 13 Jul 2015 21:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lee Sung <lsung <at> juniper.net>
To: "bug-coreutils <at> gnu.org" <bug-coreutils <at> gnu.org>
Cc: Lee Sung <lsung <at> juniper.net>
Subject: direct/file deletion
Date: Mon, 13 Jul 2015 20:04:33 +0000
[Message part 1 (text/plain, inline)]
Hi,

I cannot delete dir/file from my home directory.
[lsung <at> hw-lnx-shell3 ~/fpc_i2cs_cpld]$

[lsung <at> hw-lnx-shell3 ~/fpc_i2cs_cpld]$ ls -al
total 28
drwxr-xr-x   3 lsung ipg        4096 Jul 13 11:23 .
drwxr-xr-x  26 lsung qa-others 20480 Jul 13 11:40 ..
drwxr-xr-x   2 lsung ipg        4096 Jul 13 11:23 rtl

I want to delete  dir fpc_i2cs_cpld, but I cannot.

How would I delete directory "." and ".."

Lee Sung

[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#21051; Package coreutils. (Tue, 14 Jul 2015 06:56:02 GMT) Full text and rfc822 format available.

Message #8 received at 21051 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Lee Sung <lsung <at> juniper.net>, 21051 <at> debbugs.gnu.org
Subject: Re: bug#21051: direct/file deletion
Date: Tue, 14 Jul 2015 08:55:41 +0200
tag 21051 notabug
close 21051
stop

On 07/13/2015 10:04 PM, Lee Sung wrote:
> I cannot delete dir/file from my home directory.
> [lsung <at> hw-lnx-shell3 ~/fpc_i2cs_cpld]$
>  
> [lsung <at> hw-lnx-shell3 ~/fpc_i2cs_cpld]$ ls -al
> total 28
> drwxr-xr-x   3 lsung ipg        4096 Jul 13 11:23 .
> drwxr-xr-x  26 lsung qa-others 20480 Jul 13 11:40 ..
> drwxr-xr-x   2 lsung ipg        4096 Jul 13 11:23 rtl
>  
> I want to delete  dir fpc_i2cs_cpld, but I cannot.
>  
> How would I delete directory “.” and “..”

Thanks for the bug report.
You did not show us how you tried to delete that directory,
and what error message (or other effect) you got.

The entries "." and ".." are implicit and stand for the
current and parent directories respectively on UNIX-oide
file systems.  You'd never want to delete them directly
by these names - and the rm(1) utility of GNU coreutils
actually refuses to delete them:

  $ rm -r .
  rm: refusing to remove '.' or '..' directory: skipping '.'

However, you could remove it by it's absolute file name:

  $ rm -r "$HOME/fpc_i2cs_cpld"

Anyway, as this is unlikely a bug in the GNU coreutils, I'm
closing this as "not a bug" in our bug tracker.

Have a nice day,
Berny




Information forwarded to bug-coreutils <at> gnu.org:
bug#21051; Package coreutils. (Tue, 14 Jul 2015 22:55:01 GMT) Full text and rfc822 format available.

Message #11 received at 21051 <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: Lee Sung <lsung <at> juniper.net>
Cc: 21051 <at> debbugs.gnu.org
Subject: Re: bug#21051: direct/file deletion
Date: Tue, 14 Jul 2015 16:54:01 -0600
Lee Sung wrote:
> [lsung <at> hw-lnx-shell3 ~/fpc_i2cs_cpld]$ ls -al
> total 28
> drwxr-xr-x   3 lsung ipg        4096 Jul 13 11:23 .
> drwxr-xr-x  26 lsung qa-others 20480 Jul 13 11:40 ..
> drwxr-xr-x   2 lsung ipg        4096 Jul 13 11:23 rtl
> 
> I want to delete  dir fpc_i2cs_cpld, but I cannot.

Easiest is to change directory one above and then delete it.  The
easiest way is with rm -r -f which will perform a recursive removal of
everything in the directory depth first from the bottom up.

  cd ..
  rm -rf fpc_i2cs_cpld  # warning: recursive removal

But you could also delete it using the full path.

  rm -rf ~/fpc_i2cs_cpld  # warning: recursive removal

> How would I delete directory "." and ".."

Those entries are required infrastructure and should not be deleted.
The "." directory refers to the current directory.  The ".." refers to
the parent directory.  The ".." entry on some classic Unix file
systems may be unlinked but I don't believe that any current Linux
file system allows this.  This is a restriction imposed by the kernel
and not by coreutils.

Bob




Information forwarded to bug-coreutils <at> gnu.org:
bug#21051; Package coreutils. (Tue, 14 Jul 2015 23:01:01 GMT) Full text and rfc822 format available.

Message #14 received at 21051 <at> debbugs.gnu.org (full text, mbox):

From: Lee Sung <lsung <at> juniper.net>
To: Bob Proulx <bob <at> proulx.com>
Cc: "21051 <at> debbugs.gnu.org" <21051 <at> debbugs.gnu.org>
Subject: RE: bug#21051: direct/file deletion
Date: Tue, 14 Jul 2015 22:56:47 +0000
Bob,

I am enable to do from window.
Thank you,
Lee Sung

-----Original Message-----
From: Bob Proulx [mailto:bob <at> proulx.com] 
Sent: Tuesday, July 14, 2015 3:54 PM
To: Lee Sung
Cc: 21051 <at> debbugs.gnu.org
Subject: Re: bug#21051: direct/file deletion

Lee Sung wrote:
> [lsung <at> hw-lnx-shell3 ~/fpc_i2cs_cpld]$ ls -al total 28
> drwxr-xr-x   3 lsung ipg        4096 Jul 13 11:23 .
> drwxr-xr-x  26 lsung qa-others 20480 Jul 13 11:40 ..
> drwxr-xr-x   2 lsung ipg        4096 Jul 13 11:23 rtl
> 
> I want to delete  dir fpc_i2cs_cpld, but I cannot.

Easiest is to change directory one above and then delete it.  The easiest way is with rm -r -f which will perform a recursive removal of everything in the directory depth first from the bottom up.

  cd ..
  rm -rf fpc_i2cs_cpld  # warning: recursive removal

But you could also delete it using the full path.

  rm -rf ~/fpc_i2cs_cpld  # warning: recursive removal

> How would I delete directory "." and ".."

Those entries are required infrastructure and should not be deleted.
The "." directory refers to the current directory.  The ".." refers to the parent directory.  The ".." entry on some classic Unix file systems may be unlinked but I don't believe that any current Linux file system allows this.  This is a restriction imposed by the kernel and not by coreutils.

Bob




Information forwarded to bug-coreutils <at> gnu.org:
bug#21051; Package coreutils. (Wed, 15 Jul 2015 16:48:02 GMT) Full text and rfc822 format available.

Message #17 received at 21051 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Bob Proulx <bob <at> proulx.com>
Cc: 21051 <at> debbugs.gnu.org, Lee Sung <lsung <at> juniper.net>
Subject: Re: bug#21051: direct/file deletion
Date: Wed, 15 Jul 2015 18:47:08 +0200
Bob Proulx <bob <at> proulx.com> writes:

> But you could also delete it using the full path.
>
>   rm -rf ~/fpc_i2cs_cpld  # warning: recursive removal

A relative name will do as well.

$ rm -rf ../fpc_i2cs_cpld

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-coreutils <at> gnu.org:
bug#21051; Package coreutils. (Thu, 16 Jul 2015 13:22:01 GMT) Full text and rfc822 format available.

Message #20 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ruediger Meier <sweet_f_a <at> gmx.de>
To: bug-coreutils <at> gnu.org
Cc: "21051 <at> debbugs.gnu.org" <21051 <at> debbugs.gnu.org>,
 Bob Proulx <bob <at> proulx.com>, Lee Sung <lsung <at> juniper.net>
Subject: Re: bug#21051: direct/file deletion
Date: Thu, 16 Jul 2015 15:20:57 +0200
On Wednesday 15 July 2015, Lee Sung wrote:
> > How would I delete directory "." and ".."
>
> Those entries are required infrastructure and should not be deleted.
> The "." directory refers to the current directory.  The ".." refers
> to the parent directory.  The ".." entry on some classic Unix file
> systems may be unlinked but I don't believe that any current Linux
> file system allows this.  This is a restriction imposed by the kernel
> and not by coreutils.

I understand why "." and ".." links can't or at least should not be 
removed. And maybe it would be also inconsistent behavior to follow 
these links and to remove the original target directory.

But I don't understand why "rm -rf ." does not delete at least all 
content within ".".

My use case would be to cleanup "build" directories to start freshly 
like this:

$ pwd
/home/rudi/devel/coreutils/=build-1234
$ rm -rf .
$ ../configure

IMO all workarounds to cleanup "." (inclusive dot-files) are just 
annoying.

cu,
Rudi








Information forwarded to bug-coreutils <at> gnu.org:
bug#21051; Package coreutils. (Thu, 16 Jul 2015 13:22:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#21051; Package coreutils. (Thu, 16 Jul 2015 14:50:02 GMT) Full text and rfc822 format available.

Message #26 received at 21051 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Ruediger Meier <sweet_f_a <at> gmx.de>, 21051 <at> debbugs.gnu.org
Cc: bob <at> proulx.com, lsung <at> juniper.net
Subject: Re: bug#21051: direct/file deletion
Date: Thu, 16 Jul 2015 08:49:29 -0600
[Message part 1 (text/plain, inline)]
On 07/16/2015 07:20 AM, Ruediger Meier wrote:
> On Wednesday 15 July 2015, Lee Sung wrote:
>>> How would I delete directory "." and ".."
>>
>> Those entries are required infrastructure and should not be deleted.
>> The "." directory refers to the current directory.  The ".." refers
>> to the parent directory.  The ".." entry on some classic Unix file
>> systems may be unlinked but I don't believe that any current Linux
>> file system allows this.  This is a restriction imposed by the kernel
>> and not by coreutils.
> 
> I understand why "." and ".." links can't or at least should not be 
> removed. And maybe it would be also inconsistent behavior to follow 
> these links and to remove the original target directory.
> 
> But I don't understand why "rm -rf ." does not delete at least all 
> content within ".".

Because POSIX says so:
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."

If you think POSIX is wrong, and should allow 'rm -rf .' as a way to
empty '.' while leaving the directory itself intact (but probably still
failing the overall command and setting $? to 1), then propose a bug
report to the POSIX folks (especially helpful would be if you could
provide evidence that historical Unix from 30 years ago behaved in that
manner, and that it was an inadvertent wording choice in POSIX that
prevents the historical behavior):

http://austingroupbugs.net/main_page.php

> 
> My use case would be to cleanup "build" directories to start freshly 
> like this:
> 
> $ pwd
> /home/rudi/devel/coreutils/=build-1234
> $ rm -rf .
> $ ../configure
> 
> IMO all workarounds to cleanup "." (inclusive dot-files) are just 
> annoying.

These work (but I agree that they are much longer to type)

rm -rf -- * .??* .[!.]
(except that has problems with command line length)

find . \! -name . | xargs rm -rf

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#21051; Package coreutils. (Thu, 16 Jul 2015 15:07:01 GMT) Full text and rfc822 format available.

Message #29 received at 21051 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Eric Blake <eblake <at> redhat.com>, Ruediger Meier <sweet_f_a <at> gmx.de>, 
 21051 <at> debbugs.gnu.org
Cc: bob <at> proulx.com, lsung <at> juniper.net
Subject: Re: bug#21051: direct/file deletion
Date: Thu, 16 Jul 2015 17:06:32 +0200
On 07/16/2015 04:49 PM, Eric Blake wrote:
> On 07/16/2015 07:20 AM, Ruediger Meier wrote:
>> IMO all workarounds to cleanup "." (inclusive dot-files) are just
>> annoying.
>
> These work (but I agree that they are much longer to type)
>
> rm -rf -- * .??* .[!.]
> (except that has problems with command line length)
>
> find . \! -name . | xargs rm -rf

GNU find does it, too:

  $ find . -mindepth 1 -delete

Have a nice day,
Berny




Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Oct 2018 02:38:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 21051 <at> debbugs.gnu.org and Lee Sung <lsung <at> juniper.net> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Oct 2018 02:38:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 20 Nov 2018 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 218 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.