changeset 748:8947c0d35e58 0.4.2

The Linux kernel "make clean" calls rm -f with no arguments, which apparently is not an error.
author Rob Landley <rob@landley.net>
date Wed, 12 Dec 2012 21:13:12 -0600
parents 68d6c1ce7bba
children 9a20a126313a
files toys/posix/rm.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/toys/posix/rm.c	Mon Dec 10 21:08:42 2012 -0600
+++ b/toys/posix/rm.c	Wed Dec 12 21:13:12 2012 -0600
@@ -4,7 +4,7 @@
  *
  * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html
 
-USE_RM(NEWTOY(rm, "<1fiRr[-fi]", TOYFLAG_BIN))
+USE_RM(NEWTOY(rm, "fiRr[-fi]", TOYFLAG_BIN))
 
 config RM
   bool "rm"
@@ -76,6 +76,9 @@
 {
   char **s;
 
+  // Can't use <1 in optstring because zero arguments with -f isn't an error
+  if (!toys.optc && !(toys.optflags & FLAG_f)) error_exit("Needs 1 argument");
+
   for (s = toys.optargs; *s; s++) {
     if (!strcmp(*s, "/")) {
       error_msg("rm /. if you mean it");