From: "Roberto E. Vargas Caballero" <k...@shike2.com>

POSIX explicitely mandates to ignore . or .. to avoid
pitfals like rm -r .* and no having files that begin
with a dot.
---
 rm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/rm.c b/rm.c
index 2391d68..1f23c09 100644
--- a/rm.c
+++ b/rm.c
@@ -1,5 +1,6 @@
 /* See LICENSE file for copyright and license details. */
 #include <fcntl.h>
+#include  <string.h>
 
 #include "fs.h"
 #include "util.h"
@@ -37,8 +38,10 @@ main(int argc, char *argv[])
                        return 0;
        }
 
-       for (; *argv; argc--, argv++)
-               recurse(AT_FDCWD, *argv, NULL, &r);
+       for (; *argv; argc--, argv++) {
+               if (strcmp(*argv, ".") && strcmp(*argv, ".."))
+                       recurse(AT_FDCWD, *argv, NULL, &r);
+       }
 
        return rm_status || recurse_status;
 }
-- 
2.46.1


Reply via email to