mirror of
git://git.suckless.org/sbase
synced 2026-01-26 05:37:54 +00:00
rm: Don't attempt to remove . or ..
POSIX explicitely mandates to ignore . or .. to avoid pitfals like rm -r .* and no having files that begin with a dot.
This commit is contained in:
parent
0df8cdc12d
commit
3f7c7c2497
7
rm.c
7
rm.c
@ -1,5 +1,6 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fs.h"
|
||||
#include "util.h"
|
||||
@ -37,8 +38,10 @@ main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (; *argv; argc--, argv++)
|
||||
recurse(AT_FDCWD, *argv, NULL, &r);
|
||||
for (; *argv; argc--, argv++) {
|
||||
if (strcmp(*argv, ".") && strcmp(*argv, ".."))
|
||||
recurse(AT_FDCWD, *argv, NULL, &r);
|
||||
}
|
||||
|
||||
return rm_status || recurse_status;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user