OSDN Git Service

Only remove directories when removing recursively.
authorMatt Kraai <kraai@debian.org>
Wed, 20 Sep 2000 23:10:21 +0000 (23:10 -0000)
committerMatt Kraai <kraai@debian.org>
Wed, 20 Sep 2000 23:10:21 +0000 (23:10 -0000)
coreutils/rm.c
rm.c

index 275c059..c93a94c 100644 (file)
@@ -45,6 +45,11 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
 
 static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
 {
+       if (recursiveFlag == FALSE) {
+               errno = EISDIR;
+               perror(fileName);
+               return (FALSE);
+       } 
        if (rmdir(fileName) < 0) {
                perror(fileName);
                return (FALSE);
diff --git a/rm.c b/rm.c
index 275c059..c93a94c 100644 (file)
--- a/rm.c
+++ b/rm.c
@@ -45,6 +45,11 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
 
 static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
 {
+       if (recursiveFlag == FALSE) {
+               errno = EISDIR;
+               perror(fileName);
+               return (FALSE);
+       } 
        if (rmdir(fileName) < 0) {
                perror(fileName);
                return (FALSE);