On Mon, Aug 29, 2005 at 02:17:10PM -0700, Paul Eggert wrote:

> The latter, but this comes up so often (I must have seen this reported
> a hundred times...) that I thought I'd try to improve the diagnostic.
> I installed this:
> 
> 2005-08-29  Paul Eggert  <[EMAIL PROTECTED]>
> 
>       * NEWS: "rm -FOO" now suggests "rm ./-FOO" if the file "-FOO"
>       exists and "-FOO" is not a valid option.
>       * src/rm.c: Include lstat.h, quotearg.h.
>       (diagnose_leading_hyphen): New function.
>       (main): Use it.

Good plan.  While I think about it, it might also be worth enhancing
the --help output to point out that "rm ./*" is safe while "rm *"
might do things you did not expect (think "touch ./-rf").

I attach a patch (with ChangeLog entry) which includes such a change
to the help message.  I have snail-mailed a completed copyright
assignment for coreutils, but it hasn't turned up in copyright.list
yet (in any case this particular change is tiny).

Regards,
James.

2005-08-29  James Youngman  <[EMAIL PROTECTED]> (tiny change)

        * src/rm.c (usage): Suggest "rm ./*" in preference 
        to "rm *" in the help message.

Index: src/rm.c
===================================================================
RCS file: /cvsroot/coreutils/coreutils/src/rm.c,v
retrieving revision 1.134
diff -u -r1.134 rm.c
--- src/rm.c    14 May 2005 07:58:37 -0000      1.134
+++ src/rm.c    29 Aug 2005 22:25:53 -0000
@@ -136,6 +136,14 @@
   %s ./-foo\n\
 "),
              base, base);
+      printf (_("\
+\n\
+Similarly, if you want to remove all the files in the current directory,\n\
+  %s ./*\n\
+is much safer than\n\
+  %s *\n\
+in case the shell's expansion of '*' includes any files starting with '-'.\n"),
+             base, base);
       fputs (_("\
 \n\
 Note that if you use rm to remove a file, it is usually possible to recover\n\
_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to