aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/rm.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-12-12 21:13:12 -0600
committerRob Landley <rob@landley.net>2012-12-12 21:13:12 -0600
commit5806b9ff1656d9d32563a61457cb64ed025002dd (patch)
tree2d097dcd7c2066b8e45320efef3736bde6e9bbcc /toys/posix/rm.c
parentb1c002ac55339d7b7ec53214397f841c56cf6488 (diff)
downloadtoybox-5806b9ff1656d9d32563a61457cb64ed025002dd.tar.gz
The Linux kernel "make clean" calls rm -f with no arguments, which apparently is not an error.0.4.2
Diffstat (limited to 'toys/posix/rm.c')
-rw-r--r--toys/posix/rm.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/toys/posix/rm.c b/toys/posix/rm.c
index 59d5061b..c9f741ca 100644
--- a/toys/posix/rm.c
+++ b/toys/posix/rm.c
@@ -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 @@ void rm_main(void)
{
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");