summaryrefslogtreecommitdiff
path: root/rm.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>1999-11-15 17:33:30 +0000
committerEric Andersen <andersen@codepoet.org>1999-11-15 17:33:30 +0000
commita9c95ea6551eb3d894fcc56822c8aa394972b699 (patch)
tree59359f25ba4bd356c2dfce79735fb66db4bb4151 /rm.c
parent80974fad03689b4344888820d89b514d4e4d166b (diff)
downloadbusybox-w32-a9c95ea6551eb3d894fcc56822c8aa394972b699.tar.gz
busybox-w32-a9c95ea6551eb3d894fcc56822c8aa394972b699.tar.bz2
busybox-w32-a9c95ea6551eb3d894fcc56822c8aa394972b699.zip
Updates
Diffstat (limited to 'rm.c')
-rw-r--r--rm.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/rm.c b/rm.c
index e6132ab35..ba5d30e92 100644
--- a/rm.c
+++ b/rm.c
@@ -26,6 +26,7 @@
26#include <time.h> 26#include <time.h>
27#include <utime.h> 27#include <utime.h>
28#include <dirent.h> 28#include <dirent.h>
29#include <errno.h>
29 30
30static const char* rm_usage = "rm [OPTION]... FILE...\n\n" 31static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
31"Remove (unlink) the FILE(s).\n\n" 32"Remove (unlink) the FILE(s).\n\n"
@@ -59,6 +60,7 @@ static int dirAction(const char *fileName, struct stat* statbuf)
59 60
60extern int rm_main(int argc, char **argv) 61extern int rm_main(int argc, char **argv)
61{ 62{
63 struct stat statbuf;
62 64
63 if (argc < 2) { 65 if (argc < 2) {
64 usage( rm_usage); 66 usage( rm_usage);
@@ -85,9 +87,14 @@ extern int rm_main(int argc, char **argv)
85 87
86 while (argc-- > 0) { 88 while (argc-- > 0) {
87 srcName = *(argv++); 89 srcName = *(argv++);
88 if (recursiveAction( srcName, recursiveFlag, FALSE, TRUE, 90 if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0 && errno == ENOENT) {
89 fileAction, dirAction) == FALSE) { 91 /* do not reports errors for non-existent files if -f, just skip them */
90 exit( FALSE); 92 }
93 else {
94 if (recursiveAction( srcName, recursiveFlag, FALSE,
95 TRUE, fileAction, dirAction) == FALSE) {
96 exit( FALSE);
97 }
91 } 98 }
92 } 99 }
93 exit( TRUE); 100 exit( TRUE);