Subject: bug#10819: [BUG][RM]

From: "Voelker, Bernhard" <[email-masked]>
Date: Thu, 16 Feb 2012 13:31:59 +0100

Jim Meyering wrote:

> Voelker, Bernhard wrote:
> 
> > I think Davide's point is not about the # comment ... rm won't see
> > that on argv anyway. The point is that 'rm -f' does not complain about
> > missing operands while 'rm' does:
> >
> >   $ rm
> >   rm: missing operand
> >   Try `rm --help' for more information.
> >   $ rm -f
> >   $
> >
> > According to the info, '-f' just silences error messages for files
> > which do not exist (and never to prompt for confirmation), but why
> > should it also affect the "missing operand" message?
> 
> Two reasons:
> 
>  - that's what rm -f has always done
>  - because that's more useful.  Otherwise, "rm -rf $file_list" would
>    have to be wrapped in code to handle specially the case in which
>    $file_list is empty.

Good point.
That means, the info page could be enhanced to mention that
special case (see below).

Have a nice day,
Berny

>From 55d64bcdfdba4726c6e2668066bb25f4bfa6c0b6 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email-masked]>
Date: Thu, 16 Feb 2012 13:29:44 +0100
Subject: [PATCH] doc: document 'rm -f' better
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* doc/coreutils.texi (rm invocation): Mention that the option '-f' also
silences the message for missing operands which is useful in scripts
e.g. for "rm -f $file_list" when $file_list is empty.
* src/rm.c (usage):  Likewise.
Reported by Jérémy Magrin in http://bugs.gnu.org/10819
---
 doc/coreutils.texi |    2 +-
 src/rm.c           |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 02c3a2a..87624c2 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -8769,7 +8769,7 @@ The program accepts the following options.  Also see @ref{Common options}.
 @itemx --force
 @opindex -f
 @opindex --force
-Ignore nonexistent files and never prompt the user.
+Ignore nonexistent files, missing operands and never prompt the user.
 Ignore any previous @option{--interactive} (@option{-i}) option.
 
 @item -i
diff --git a/src/rm.c b/src/rm.c
index db525d0..02809f2 100644
--- a/src/rm.c
+++ b/src/rm.c
@@ -135,7 +135,7 @@ usage (int status)
       fputs (_("\
 Remove (unlink) the FILE(s).\n\
 \n\
-  -f, --force           ignore nonexistent files, never prompt\n\
+  -f, --force           ignore nonexistent files and arguments, never prompt\n\
   -i                    prompt before every removal\n\
 "), stdout);
       fputs (_("\
-- 
1.7.7