Add history and config-struct to recurse

For loop detection, a history is mandatory. In the process of also
adding a flexible struct to recurse, the recurse-definition was moved
to fs.h.
The motivation behind the struct is to allow easy extensions to the
recurse-function without having to change the prototypes of all
functions in the process.
Adding flags is really simple as well now.

Using the recursor-struct, it's also easier to see which defaults
apply to a program (for instance, which type of follow, ...).

Another change was to add proper stat-lstat-usage in recurse. It
was wrong before.
This commit is contained in:
FRIGN
2015-03-13 00:25:32 +01:00
parent 3b187f4826
commit 9fd4a745f8
11 changed files with 131 additions and 66 deletions

6
rm.c
View File

@@ -11,6 +11,8 @@ usage(void)
int
main(int argc, char *argv[])
{
struct recursor r = { .fn = rm, .hist = NULL, .depth = 0, .follow = 'P', .flags = 0};
ARGBEGIN {
case 'f':
rm_fflag = 1;
@@ -31,7 +33,7 @@ main(int argc, char *argv[])
}
for (; *argv; argc--, argv++)
rm(*argv, 0, NULL);
rm(*argv, NULL, &r);
return rm_status;
return rm_status || recurse_status;
}