rm: removing empty dirs is okay
This commit is contained in:
parent
20d526391d
commit
196e81c5fb
10
rm.c
10
rm.c
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user