Project

General

Profile

Bug #4816

rm does not print error messages when -f is used

Added by Andrew Stormont about 5 years ago. Updated over 4 years ago.

Status:
In Progress
Priority:
Normal
Category:
-
Start date:
2014-04-26
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage

Description

When the -f option is passed to rm it does not print error messages meaning the only way to spot an error is to check the exit code. The manpage is also not clear on this. I think we should always be printing errors.

History

#1

Updated by Gary Mills about 5 years ago

This exerpt from the man page seems clear to me:

@
/usr/xpg4/bin/rm
The following options are supported for /usr/xpg4/bin/rm
only:

f    Does not prompt for confirmation. Does not write diag
nostic messages or modify the exit status in the case
of non-existent operands. Any previous occurrences of
the -i option is ignored.
@

That's the same as the Open Group standard.

#2

Updated by Andrew Stormont about 5 years ago

Yes, but it only says "in the case of non-existent operands". What about other cases such as permission errors?

#3

Updated by Gary Mills about 5 years ago

About all I can add is the typical use in a shell script. The construct:

if [ -f $F ]
then
rm $F
done

can be replaced by:

rm -f $F

#4

Updated by Andrew Stormont about 5 years ago

That's pretty much why I filed the bug. I had a script that called 'rm -f' but it didn't have permission to remove the file and blew up. I ended up running truss on rm to see what was happening - not very nice when you consider GNU rm will just print out an error.

I prepared this webrev which makes rm a little more verbose when it comes to errors and also adds support for the -v flag. I'd like to submit it for review but I wonder if it might upset some of the standards obsessed folk within the illumos community.

http://cr.illumos.org/~webrev/andy_js/4815/

#5

Updated by Andrew Stormont about 5 years ago

  • Status changed from New to In Progress
  • Assignee set to Andrew Stormont
  • Difficulty changed from Medium to Bite-size
#6

Updated by Garrett D'Amore over 4 years ago

Um. rm -f not printing messages is a legacy compatibility concern. Under POSIX (xpg4) it does print them.

Also available in: Atom PDF