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
1 changed files with 2 additions and 8 deletions

10
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 && rm(argv[optind]);
S_ISDIR(st.st_mode))
fprintf(stderr, "%s: is a directory\n", argv[optind]);
else
rm(argv[optind]);
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }