fix rm -f
This commit is contained in:
parent
4c6c379812
commit
be6e177f6e
2
rm.1
2
rm.1
|
@ -11,7 +11,7 @@ removes the given files and directories.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-f
|
.B \-f
|
||||||
ignored, for compatibility.
|
ignore files that cannot be removed.
|
||||||
.TP
|
.TP
|
||||||
.B \-r
|
.B \-r
|
||||||
remove directories recursively.
|
remove directories recursively.
|
||||||
|
|
7
rm.c
7
rm.c
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
static void rm(const char *);
|
static void rm(const char *);
|
||||||
|
|
||||||
static bool rflag = 0;
|
static bool fflag = false;
|
||||||
|
static bool rflag = false;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
|
@ -20,6 +21,7 @@ main(int argc, char *argv[])
|
||||||
while((c = getopt(argc, argv, "fr")) != -1)
|
while((c = getopt(argc, argv, "fr")) != -1)
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'f':
|
case 'f':
|
||||||
|
fflag = true;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
rflag = true;
|
rflag = true;
|
||||||
|
@ -54,5 +56,6 @@ void rm(const char *path)
|
||||||
if(remove(path) == 0)
|
if(remove(path) == 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
eprintf("remove %s:", path);
|
if(!fflag)
|
||||||
|
eprintf("remove %s:", path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user