From 7c22b771625cee60ca37be7c4cd27f2c360d0aba Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 20 Sep 2000 23:10:21 +0000 Subject: [PATCH] Only remove directories when removing recursively. --- coreutils/rm.c | 5 +++++ rm.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/coreutils/rm.c b/coreutils/rm.c index 275c05946..c93a94ce1 100644 --- a/coreutils/rm.c +++ b/coreutils/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); diff --git a/rm.c b/rm.c index 275c05946..c93a94ce1 100644 --- 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); -- 2.25.1