Bug #4816

rm does not print error messages when -f is used

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

In Progress
Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:


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.



Updated by Gary Mills about 6 years ago

This exerpt from the man page seems clear to me:

The following options are supported for /usr/xpg4/bin/rm

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.


Updated by Andrew Stormont about 6 years ago

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


Updated by Gary Mills about 6 years ago

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

if [ -f $F ]
rm $F

can be replaced by:

rm -f $F


Updated by Andrew Stormont about 6 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.


Updated by Andrew Stormont about 6 years ago

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

Updated by Garrett D'Amore over 5 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