ftpd: do not use nasty tricks for re-execing if we are on MMU machine.
[oweals/busybox.git] / coreutils / rm.c
index 61e3e7010a59e6f9f489238a0fc4c23a241e243d..975f2267b1f219cfd427601b2707e0654c0b009f 100644 (file)
  * Size reduction.
  */
 
-#include "busybox.h"
+#include "libbb.h"
 
 /* This is a NOFORK applet. Be very careful! */
 
-int rm_main(int argc, char **argv);
-int rm_main(int argc, char **argv)
+int rm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int rm_main(int argc UNUSED_PARAM, char **argv)
 {
        int status = 0;
        int flags = 0;
        unsigned opt;
 
        opt_complementary = "f-i:i-f";
-       opt = getopt32(argc, argv, "fiRr");
+       opt = getopt32(argv, "fiRr");
        argv += optind;
        if (opt & 1)
                flags |= FILEUTILS_FORCE;
@@ -38,9 +38,9 @@ int rm_main(int argc, char **argv)
 
        if (*argv != NULL) {
                do {
-                       const char *base = bb_get_last_path_component(*argv);
+                       const char *base = bb_get_last_path_component_strip(*argv);
 
-                       if ((base[0] == '.') && (!base[1] || ((base[1] == '.') && !base[2]))) {
+                       if (DOT_OR_DOTDOT(base)) {
                                bb_error_msg("cannot remove '.' or '..'");
                        } else if (remove_file(*argv, flags) >= 0) {
                                continue;