GNU bug report logs - #16669
rm: inconsistent 'rm -ir' prompting behavior (POSIX issue)

Previous Next

Package: coreutils;

Reported by: Eric Blake <eblake <at> redhat.com>

Date: Thu, 6 Feb 2014 16:40:02 UTC

Severity: wishlist

Tags: confirmed

To reply to this bug, email your comments to 16669 AT debbugs.gnu.org.

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#16669; Package coreutils. (Thu, 06 Feb 2014 16:40:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric Blake <eblake <at> redhat.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 06 Feb 2014 16:40:02 GMT) Full text and rfc822 format available.

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

From: Eric Blake <eblake <at> redhat.com>
To: bug-coreutils <at> gnu.org
Subject: inconsistent 'rm -ir' prompting behavior
Date: Thu, 06 Feb 2014 09:39:10 -0700
[Message part 1 (text/plain, inline)]
On today's Austin Group call, we discussed
http://austingroupbugs.net/view.php?id=802 regarding 'rm' behavior.

They pointed out that GNU has an optimization not allowed by a strict
reading of the current standard:

$ mkdir foo
$ rm -ir foo
rm: remove directory ‘foo’?

Whether you answer yes or no, the point remains: rm only prompted once
about removing the empty directory.  Compare that to other
implementations, such as Solaris:

$ rm -ir /tmp/foo
rm: examine files in directory /tmp/foo (yes/no)? y
rm: remove /tmp/foo (yes/no)? y
$

Note that the optimization implies that we did a readdir() on the
directory before deciding whether to prompt, in order to learn if it was
empty; and that readdir() modifies directory atime; in the Solaris
implementation, readdir() is not even attempted until after a positive
prompt response, which means directory atime is unchanged if the user
chooses not to descend.

Meanwhile, for a non-empty directory, we DO prompt twice for the directory:

$ touch foo/bar
$ rm -ir foo
rm: descend into directory ‘foo’? y
rm: remove regular empty file ‘foo/bar’? y
rm: remove directory ‘foo’?

Here, we get the POSIX-mandated double prompting, once to descend, and
once after recursion is complete to see whether to remove the now-empty
directory.  The argument is whether the GNU optimization of prompting
only once for an empty directory violates POSIX (and where it is
observable by a new directory atime), or whether we should patch POSIX
to allow the GNU optimization.  In the meeting, I ended up with an
action item to right the bug report against POSIX to propose wording
that would allow the GNU behavior.

Conversely, consider:

$ rm -ir foo
rm: descend into directory ‘foo’? y
rm: remove regular empty file ‘foo/bar’? n
rm: remove directory ‘foo’? y
rm: cannot remove ‘foo’: Directory not empty

Why on earth are we prompting to remove 'foo' when we KNOW it is
non-empty because the user specifically asked to not remove foo/bar?  If
we can optimize from two prompts down to one for the empty directory
case, why are we not optimizing and avoiding asking a useless prompt for
a known non-empty directory?  So, while writing my POSIX bug report,
should I also allow for an optimization of omitting the second prompt
for a known non-empty directory (known because of a negative answer to
prompts on its children), even though GNU does not yet implement that
optimization?

-- 
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#16669; Package coreutils. (Thu, 06 Feb 2014 17:04:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eric Blake <eblake <at> redhat.com>, 16669 <at> debbugs.gnu.org
Subject: Re: bug#16669: inconsistent 'rm -ir' prompting behavior
Date: Thu, 06 Feb 2014 09:03:50 -0800
On 02/06/2014 08:39 AM, Eric Blake wrote:
> should I also allow for an optimization of omitting the second prompt
> for a known non-empty directory

I would, yes.  Thanks for catching that.

> (known because of a negative answer to
> prompts on its children)
It might also be known because of a failed attempt to remove a child, 
and this optimization should be allowed as well.




Information forwarded to bug-coreutils <at> gnu.org:
bug#16669; Package coreutils. (Thu, 06 Feb 2014 17:34:01 GMT) Full text and rfc822 format available.

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

From: Eric Blake <eblake <at> redhat.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>, 16669 <at> debbugs.gnu.org
Subject: Re: bug#16669: inconsistent 'rm -ir' prompting behavior
Date: Thu, 06 Feb 2014 10:33:35 -0700
[Message part 1 (text/plain, inline)]
On 02/06/2014 10:03 AM, Paul Eggert wrote:
> On 02/06/2014 08:39 AM, Eric Blake wrote:
>> should I also allow for an optimization of omitting the second prompt
>> for a known non-empty directory
> 
> I would, yes.  Thanks for catching that.
> 
>> (known because of a negative answer to
>> prompts on its children)
> It might also be known because of a failed attempt to remove a child,
> and this optimization should be allowed as well.

http://austingroupbugs.net/view.php?id=819 was created to attempt this,
although it may need another round of word-smithing to make sure it is
correct for what we want.

-- 
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#16669; Package coreutils. (Thu, 06 Feb 2014 17:45:02 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Eric Blake <eblake <at> redhat.com>
Cc: 16669 <at> debbugs.gnu.org
Subject: Re: bug#16669: inconsistent 'rm -ir' prompting behavior
Date: Thu, 06 Feb 2014 17:44:11 +0000
On 02/06/2014 04:39 PM, Eric Blake wrote:
> On today's Austin Group call, we discussed
> http://austingroupbugs.net/view.php?id=802 regarding 'rm' behavior.
> 
> They pointed out that GNU has an optimization not allowed by a strict
> reading of the current standard:
> 
> $ mkdir foo
> $ rm -ir foo
> rm: remove directory ‘foo’?
> 
> Whether you answer yes or no, the point remains: rm only prompted once
> about removing the empty directory

[snip]

> Conversely, consider:
> 
> $ rm -ir foo
> rm: descend into directory ‘foo’? y
> rm: remove regular empty file ‘foo/bar’? n
> rm: remove directory ‘foo’? y
> rm: cannot remove ‘foo’: Directory not empty
> 
> Why on earth are we prompting to remove 'foo' when we KNOW it is
> non-empty because the user specifically asked to not remove foo/bar?  If
> we can optimize from two prompts down to one for the empty directory
> case, why are we not optimizing and avoiding asking a useless prompt for
> a known non-empty directory?

The different handling could be useful I think.

When we determine there are no files in a dir,
then only one prompt is necessary.

If we determine files are present a separate prompt
is useful to cater for the following sequence
in terminal 1 and terminal 2.

1> $ rm -ir foo
1> rm: descend into directory ‘foo’? y
1> rm: remove regular empty file ‘foo/bar’? n
1> rm: remove directory ‘foo’?

2> mv foo/bar /safe/foo  # Handle this unknown file _independently_

1> y

thanks,
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#16669; Package coreutils. (Fri, 19 Oct 2018 23:35:02 GMT) Full text and rfc822 format available.

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

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Pádraig Brady <P <at> draigBrady.com>,
 Eric Blake <eblake <at> redhat.com>
Cc: 16669 <at> debbugs.gnu.org
Subject: Re: bug#16669: inconsistent 'rm -ir' prompting behavior
Date: Fri, 19 Oct 2018 17:34:08 -0600
(triaging old bugs)

Eric, Pádraig,

On 06/02/14 10:44 AM, Pádraig Brady wrote:
> On 02/06/2014 04:39 PM, Eric Blake wrote:
>> On today's Austin Group call, we discussed
>> http://austingroupbugs.net/view.php?id=802 regarding 'rm' behavior.
>>

Was there ever a resolution (or a committed fix)
for the "rm -ir" issue in:
  https://bugs.gnu.org/16669


-assaf





Information forwarded to bug-coreutils <at> gnu.org:
bug#16669; Package coreutils. (Sun, 21 Oct 2018 00:09:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Assaf Gordon <assafgordon <at> gmail.com>, Pádraig Brady
 <P <at> draigBrady.com>, Eric Blake <eblake <at> redhat.com>
Cc: 16669 <at> debbugs.gnu.org
Subject: Re: bug#16669: inconsistent 'rm -ir' prompting behavior
Date: Sat, 20 Oct 2018 17:08:23 -0700
Assaf Gordon wrote:
> Was there ever a resolution (or a committed fix)
> for the "rm -ir" issue in:
> https://bugs.gnu.org/16669

Not yet. I'd leave the bug open.




Severity set to 'wishlist' from 'normal' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 21 Oct 2018 21:28:01 GMT) Full text and rfc822 format available.

Added tag(s) confirmed. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 21 Oct 2018 21:28:01 GMT) Full text and rfc822 format available.

Changed bug title to 'rm: inconsistent 'rm -ir' prompting behavior (POSIX issue)' from 'inconsistent 'rm -ir' prompting behavior' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 21 Oct 2018 21:28:01 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 191 days ago.

Previous Next


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