rm: removing empty dirs is okay

This commit is contained in:
Connor Lane Smith 2012-05-25 21:55:31 +01:00
parent 20d526391d
commit 196e81c5fb

8
rm.c
View File

@ -11,7 +11,6 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
char c; char c;
struct stat st;
while((c = getopt(argc, argv, "fr")) != -1) while((c = getopt(argc, argv, "fr")) != -1)
switch(c) { switch(c) {
@ -24,12 +23,7 @@ main(int argc, char *argv[])
default: default:
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
for(; optind < argc; optind++) { for(; optind < argc; optind++)
if(!rm_rflag && stat(argv[optind], &st) == 0 &&
S_ISDIR(st.st_mode))
fprintf(stderr, "%s: is a directory\n", argv[optind]);
else
rm(argv[optind]); rm(argv[optind]);
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }