From 12cf23db2b618be8994cd2786d36f49b5adb6a0a Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 7 Sep 2022 11:33:00 +0300 Subject: cmd_remove: drop check for empty file From the specification: > If path does not name a directory, remove(path) shall be equivalent to unlink(path). > If path names a directory, remove(path) shall be equivalent to rmdir(path). rmdir() will remove a directory only if it is empty, so drop validation for it. --- src/exec-cmd.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/exec-cmd.c b/src/exec-cmd.c index 90a666e..8936315 100644 --- a/src/exec-cmd.c +++ b/src/exec-cmd.c @@ -361,13 +361,9 @@ int cmd_remove(int argc, char *argv[]) print_error("Error: No such file exists\n"); return 1; } - if(result == F_ISDIR) { - if(count_dir_entries(path) != 0) { - print_error("Error: Directory not empty\n"); - return 1; - } - } + /* If path names a directory, remove() shall be equivalent + to rmdir(). */ result = remove(path); if(result) { print_error("Error: %s\n", strerror(errno)); -- cgit v1.2.3-18-g5258