GNU bug report logs - #7775
rm -f emits no error message when deleting nonexistent file

Previous Next

Package: coreutils;

Reported by: Jeremy Hetzler <jeremyhetzler <at> gmail.com>

Date: Mon, 3 Jan 2011 15:55:01 UTC

Severity: normal

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7775 in the body.
You can then email your comments to 7775 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7775; Package coreutils. (Mon, 03 Jan 2011 15:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jeremy Hetzler <jeremyhetzler <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 03 Jan 2011 15:55:02 GMT) Full text and rfc822 format available.

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

From: Jeremy Hetzler <jeremyhetzler <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: rm -f emits no error message when deleting nonexistent file
Date: Mon, 3 Jan 2011 10:12:26 -0500
[Message part 1 (text/plain, inline)]
rm normally produces an error when you delete a nonexistent file. However,
under -f, you get no error message. I would argue this is a bug.

-- Jeremy Hetzler

-------------------------------------

520 $ /bin/rm nonexistent
/bin/rm: cannot remove `nonexistent': No such file or directory

521 $ /bin/rm -f nonexistent

522 $ rm --version
rm (GNU coreutils) 8.5
Packaged by Cygwin (8.5-2)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Rubin, David MacKenzie, Richard M. Stallman,
and Jim Meyering.
[Message part 2 (text/html, inline)]

Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7775; Package coreutils. (Mon, 03 Jan 2011 16:54:02 GMT) Full text and rfc822 format available.

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

From: Eric Blake <eblake <at> redhat.com>
To: Jeremy Hetzler <jeremyhetzler <at> gmail.com>
Cc: 7775 <at> debbugs.gnu.org
Subject: Re: bug#7775: rm -f emits no error message when deleting nonexistent
	file
Date: Mon, 03 Jan 2011 10:00:21 -0700
[Message part 1 (text/plain, inline)]
On 01/03/2011 08:12 AM, Jeremy Hetzler wrote:
> rm normally produces an error when you delete a nonexistent file. However,
> under -f, you get no error message. I would argue this is a bug.

Thanks for the report; however, this behavior is by design, and required
by POSIX:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html

> 1. If the file does not exist:
> 
>    a. If the -f option is not specified, rm shall write a diagnostic message to standard error.
>    b. Go on to any remaining files.

That is, the whole point of -f is to silence warnings, including
warnings about non-existent files.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Reply sent to Bob Proulx <bob <at> proulx.com>:
You have taken responsibility. (Mon, 03 Jan 2011 16:55:02 GMT) Full text and rfc822 format available.

Notification sent to Jeremy Hetzler <jeremyhetzler <at> gmail.com>:
bug acknowledged by developer. (Mon, 03 Jan 2011 16:55:02 GMT) Full text and rfc822 format available.

Message #13 received at 7775-done <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: Jeremy Hetzler <jeremyhetzler <at> gmail.com>
Cc: 7775-done <at> debbugs.gnu.org
Subject: Re: bug#7775: rm -f emits no error message when deleting
	nonexistent file
Date: Mon, 3 Jan 2011 10:01:21 -0700
Jeremy Hetzler wrote:
> rm normally produces an error when you delete a nonexistent file. However,
> under -f, you get no error message. I would argue this is a bug.

Thank you for the bug report.  But this is not a bug.  That is the
correct and desired behavior.  That is the way it is supposed to work.
This is documented in the manual.

  $ info coreutils 'rm invocation'

  `-f'
  `--force'
       Ignore nonexistent files and never prompt the user.  Ignore any
       previous `--interactive' (`-i') option.

This is core behavior and is also standardized across all Unix
systems.  Here is a pointer to the online standards documentation.

  http://pubs.opengroup.org/onlinepubs/009695399/utilities/rm.html

Bob




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

From: Jim Meyering <jim <at> meyering.net>
To: Jeremy Hetzler <jeremyhetzler <at> gmail.com>
Cc: 7775-done <at> debbugs.gnu.org
Subject: Re: bug#7775: rm -f emits no error message when deleting nonexistent
	file
Date: Mon, 03 Jan 2011 18:06:12 +0100
Jeremy Hetzler wrote:
> rm normally produces an error when you delete a nonexistent file. However,
> under -f, you get no error message. I would argue this is a bug.
...
> 520 $ /bin/rm nonexistent
> /bin/rm: cannot remove `nonexistent': No such file or directory
>
> 521 $ /bin/rm -f nonexistent
>
> 522 $ rm --version
> rm (GNU coreutils) 8.5

Thanks for the report, but that's not a bug.
Rather, it is long-standing, documented and required behavior:

    $ rm --help                                                                  :
    Usage: rm [OPTION]... FILE...
    Remove (unlink) the FILE(s).

      -f, --force           ignore nonexistent files, never prompt




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7775; Package coreutils. (Mon, 03 Jan 2011 17:13:01 GMT) Full text and rfc822 format available.

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

From: Jeremy Hetzler <jeremyhetzler <at> gmail.com>
To: Eric Blake <eblake <at> redhat.com>
Cc: 7775 <at> debbugs.gnu.org
Subject: Re: bug#7775: rm -f emits no error message when deleting nonexistent
	file
Date: Mon, 3 Jan 2011 12:18:56 -0500
[Message part 1 (text/plain, inline)]
On Mon, Jan 3, 2011 at 12:00 PM, Eric Blake <eblake <at> redhat.com> wrote:

> On 01/03/2011 08:12 AM, Jeremy Hetzler wrote:
> > rm normally produces an error when you delete a nonexistent file.
> However,
> > under -f, you get no error message. I would argue this is a bug.
>
> Thanks for the report; however, this behavior is by design, and required
> by POSIX:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html
>
> > 1. If the file does not exist:
> >
> >    a. If the -f option is not specified, rm shall write a diagnostic
> message to standard error.
> >    b. Go on to any remaining files.
>
> That is, the whole point of -f is to silence warnings, including
> warnings about non-existent files.
>
>
I see. Thanks.

---
Jeremy Hetzler
[Message part 2 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 01 Feb 2011 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 199 days ago.

Previous Next


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