don't report errors for 'rm -rf ""'. report by rkitover.
authortedu <tedu@openbsd.org>
Tue, 28 Jun 2016 15:20:13 +0000 (15:20 +0000)
committertedu <tedu@openbsd.org>
Tue, 28 Jun 2016 15:20:13 +0000 (15:20 +0000)
ok benno deraadt

bin/rm/rm.c

index 2f919ff..70476c8 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rm.c,v 1.37 2016/04/15 23:09:57 tedu Exp $    */
+/*     $OpenBSD: rm.c,v 1.38 2016/06/28 15:20:13 tedu Exp $    */
 /*     $NetBSD: rm.c,v 1.19 1995/09/07 06:48:50 jtc Exp $      */
 
 /*-
@@ -150,8 +150,11 @@ rm_tree(char **argv)
        flags = FTS_PHYSICAL;
        if (!needstat)
                flags |= FTS_NOSTAT;
-       if (!(fts = fts_open(argv, flags, NULL)))
-               err(1, NULL);
+       if (!(fts = fts_open(argv, flags, NULL))) {
+               if (!fflag || errno != ENOENT)
+                       err(1, NULL);
+               return;
+       }
        while ((p = fts_read(fts)) != NULL) {
                switch (p->fts_info) {
                case FTS_DNR: