Austin Group Defect Tracker

Aardvark Mark III


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001154 [1003.1(2016)/Issue7+TC2] Shell and Utilities Objection Enhancement Request 2017-06-25 15:58 2017-08-02 06:13
Reporter jobsnijders View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
Name Job Snijders
Organization
User Reference
Section rm
Page Number 3198-3202
Line Number 107289
Interp Status ---
Final Accepted Text
Summary 0001154: Add 'rm -v'
Description Many rm implementations provide an extension option '-v' that makes rm print the files and directories which it successfully deleted. Currently the burden is on the user to determine which set of files and directories has been deleted, which leads to a time-of-check-to-time-of-use-to-time-to-observe race between obtaining a file listing and using rm on that set of files.

One may attempt to obtain similar functionality to "rm -rfv *" by issuing "find -d * -exec rm -rf {} \; -exec echo {} \;" but that is a lot of typing.
Desired Action In "Base Specifications Issue 7 with TC2 Merged",

at page 3198 line 107245 [rm SYNOPSIS], change:

    rm [−iRr] file...
    rm -f [-iRr] [file...]

to:

    rm [−iRrv] file...
    rm -f [-iRrv] [file...]

At line 107284 [DESCRIPTION], change:

    If this fails for any reason, rm shall write a diagnostic message to standard error, do nothing more with the current file, and go on to any remaining files.

to:

    If rm successfully performed an action on the current file, and the -v option is specified, rm shall write a message containing the name of the current file to the standard output. If the action fails for any reason, rm shall write a diagnostic message to standard error, do nothing more with the current file, and go on to any remaining files.

After line 107298 [OPTIONS], insert a new paragraph:

    -v Print names of files as they are processed

After line 107404 [RATIONALE], add a paragraph:

    The addition of the −v option allows the use of rm to report which files have been deleted.
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0003801)
jobsnijders (reporter)
2017-06-25 16:05

Example output from macosx, netbsd and freebsd:

    $ mkdir dir && touch file dir/file
    $ rm -rfv dir file
    dir/file
    dir
    file
(0003802)
kre (reporter)
2017-06-25 17:37

I think if this were to be added (and no objection to that) it will
need better wording, just "Print names of files as they are processed"
says almost nothing (before the attempt is made to remove, them, after...)

And the relationship between -f (which suppresses most (or all) error
messages, and -v which deliberately requests them need to be explained.
And perhaps any relationship with -i (does -v really tell you, again,
the name of a file you just answered 'y' to removing and got no error
message about?)
(0003803)
jobsnijders (reporter)
2017-06-25 18:52

Thank you for your feedback.

I'm not sure there is an immediate relation with "-f". "-f" indeed relates to _errors_, where as "-v" prints what succeeded. On most platforms running "rm -iv" is indeed a bit verbose, since no relation exists between the two flags.

You are right that "Print names of files as they are processed" is a bit ambiguous. All "-v" implementations I am aware of specifically print _after_ a successful deletion (through a system call to unlink() or rmdir()). Perhaps "Print names of files as they are successfully deleted"?

I've collected the sentences used in "rm" man pages under [OPTIONS] from various platforms:

FreeBSD 11: "-v Be verbose when deleting files, showing them as they are removed."

DragonFly 4.8.0: "-v Be verbose when deleting files, showing them as they are removed."

NetBSD 7.1: "-v Cause rm to be verbose, showing files as they are processed."

GNU coreutils rm: "-v Print the name of each file before removing it." [red. reading the source code it appears the man page is wrong and the name is printed after successful removal]

OSX/OpenDarwin: "-v Be verbose when deleting files, showing them as they are removed."

Debian/Redhat/Suse: "-v explain what is being done"

Minix: "-v Tell what rm is removing"
(0003812)
wahern (reporter)
2017-08-02 06:13
edited on: 2017-08-02 06:13

Processing the output of -v doesn't handle the case of file names with embedded whitespace like \n. Is it worthwhile to define a new extension that doesn't address this issue? Wouldn't a simple loop like the following suffice, which is both complete in itself (no additional code necessary for post-processing of output) and which correctly handles embedded whitespace in file names?
 
  while [ $? -eq 0 ]; do
    set -- *
    test $# -gt 0 || break
    rm -fr -- "$@"
  done

More importantly, unless the application ensures mutual exclusion so that files aren't created by another process after a file name has been printed, it's not clear to me that -v can even solve TOCTTOU issues. If the application does ensure mutual exclusion, there's no TOCTTOU situation to worry about.


- Issue History
Date Modified Username Field Change
2017-06-25 15:58 jobsnijders New Issue
2017-06-25 15:58 jobsnijders Name => Job Snijders
2017-06-25 15:58 jobsnijders Section => rm
2017-06-25 15:58 jobsnijders Page Number => 3198-3202
2017-06-25 15:58 jobsnijders Line Number => 107289
2017-06-25 16:00 jobsnijders Issue Monitored: jobsnijders
2017-06-25 16:05 jobsnijders Note Added: 0003801
2017-06-25 17:37 kre Note Added: 0003802
2017-06-25 18:52 jobsnijders Note Added: 0003803
2017-08-02 06:13 wahern Note Added: 0003812
2017-08-02 06:13 wahern Note Edited: 0003812
2017-08-02 06:13 wahern Note Edited: 0003812


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