Austin Group Defect Tracker

Aardvark Mark IV

Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000819 [1003.1(2013)/Issue7+TC1] Shell and Utilities Comment Enhancement Request 2014-02-06 17:23 2019-06-10 08:54
Reporter rhansen View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Richard Hansen
Organization BBN
User Reference
Section rm
Page Number 3161
Line Number 105682-105693
Interp Status Approved
Final Accepted Text Note: 0002187
Summary 0000819: permit prompting only once when encountering a directory with 'rm -ir'
Description When 'rm -ir' encounters a directory, the standard as written requires the user to be prompted twice: Once at 2.b. (the -f option is not specified and the -i option is specified) and once at 2.d. (the -i option is specified). Some implementations (GNU coreutils, NetBSD, FreeBSD) do not follow this behavior; they prompt only once in certain conditions:

  * GNU coreutils skips one of the prompts if the directory is empty (but it
    does follow the standard if the directory is non-empty)
  * NetBSD always skips 2.d.

This bug is about permitting this alternate behavior.
Desired Action Change page 3161 lines 105691-105692 (XCU rm description), change:

    d. If the -i option is specified, rm shall write a prompt to standard error
       and read a line from the standard input.


    d. If the -i option is specified, rm may write a prompt to standard error
       and read a line from the standard input.
Tags tc2-2008
Attached Files

- Relationships
related to 0000802Closed Add 'rm -d' 

-  Notes
eblake (manager)
2014-02-06 20:17

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

By that argument, eliding the prompt for a non-empty directory is a bad idea, even if we know that the user answered no to a child (or if we hit a permissions issue that prevented removal of a child).
eblake (manager)
2014-02-06 21:41

Conversely, in the non-interactive case, the error messages make it clear that on failure to remove a child, rm is not trying to remove the parent:

$ mkdir foo
$ touch foo/bar
$ chmod 500 foo
$ rm -r foo
rm: descend into write-protected directory ‘foo’? y
rm: cannot remove ‘foo/bar’: Permission denied

It feels odd that adding '-i' determines whether rm attempts to remove what seems like a known non-empty directory - until you realize that the time spent waiting for an answer to the prompt is much longer and more likely for other things to happen in the meantime, and therefore worth the attempt when interactive.
shware_systems (reporter)
2014-02-06 21:51

Suggest adding, to accent usual use case discussed in phone call:
"No prompt is required if it may be determined that an attempt at deletion shall always fail, such as removing a parent directory when one of the child files was skipped over."

or similar language. I think the gist should be if it's possible the delete can succeed when Step 2d. reached the prompt is required, otherwise it may be skipped.

Something about if Step 2b and 2d are combined because dir is empty the prompt shall reflect this would be useful as well, applied to Step 2b.

"Dir not empty, recurse into?"
"Dir is empty, delete?"

being explicit there, to cover expectations for how coreutils does it.

Suggest adding to Step 2b.:
"If the response is affirmative and file is a subdirectory with zero file count, an implementation may indicate this in the prompt and and skip to Step 4."

Additionally, so it isn't left as ambiguous, adding after that:
"When file is a subdirectory with zero file count and not marked read only, it is (unspecified/implementation-defined) whether an attempt to determine the file count shall cause a change in any time stamp maintained for that file."
geoffclare (manager)
2014-02-07 09:57

As per Eric's note Note: 0002123, the BSD behaviour should be considered a bug.
I think the only acceptable optimization is to skip the prompt in 2b if
the directory is empty.

I suggest inserting the following text at the start of step 2b (page 3161
line 105682):

    If file is an empty directory, rm may skip to step 2d.
geoffclare (manager)
2014-03-20 15:14
edited on: 2014-03-20 15:15

Interpretation response
The standard states the requirements for prompting by rm, and
conforming implementations must conform to this. However, concerns
have been raised about this which are being referred to the sponsor.

The standard does not allow an optimization that is currently in use.

Notes to the Editor (not part of this interpretation):
Insert the following text at the start of step 2b (page 3161 line

    If file is an empty directory, rm may skip to step 2d.

ajosey (manager)
2014-04-01 13:33

Interpretation proposed: 1 April 2014
ajosey (manager)
2014-05-01 10:54

Interpretation approved May 1 2014

- Issue History
Date Modified Username Field Change
2014-02-06 17:23 rhansen New Issue
2014-02-06 17:23 rhansen Name => Richard Hansen
2014-02-06 17:23 rhansen Organization => BBN
2014-02-06 17:23 rhansen Section => rm
2014-02-06 17:23 rhansen Page Number => 3161
2014-02-06 17:23 rhansen Line Number => 105682-105693
2014-02-06 17:32 eblake Relationship added related to 0000802
2014-02-06 20:17 eblake Note Added: 0002128
2014-02-06 21:41 eblake Note Added: 0002129
2014-02-06 21:51 shware_systems Note Added: 0002130
2014-02-07 09:57 geoffclare Note Added: 0002132
2014-03-20 15:14 geoffclare Interp Status => Pending
2014-03-20 15:14 geoffclare Note Added: 0002187
2014-03-20 15:14 geoffclare Status New => Interpretation Required
2014-03-20 15:14 geoffclare Resolution Open => Accepted As Marked
2014-03-20 15:15 geoffclare Note Edited: 0002187
2014-03-20 15:15 geoffclare Tag Attached: tc2-2008
2014-03-20 15:16 geoffclare Final Accepted Text => Note: 0002187
2014-04-01 13:33 ajosey Interp Status Pending => Proposed
2014-04-01 13:33 ajosey Note Added: 0002212
2014-05-01 10:54 ajosey Interp Status Proposed => Approved
2014-05-01 10:54 ajosey Note Added: 0002237
2019-06-10 08:54 agadmin Status Interpretation Required => Closed

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker