Add maxdepth to recurse()

This also makes more sense.
This commit is contained in:
FRIGN
2015-04-18 22:04:49 +02:00
committed by sin
parent e14d9412f8
commit 7b2465c101
10 changed files with 54 additions and 45 deletions

View File

@@ -17,7 +17,7 @@ chmodr(const char *path, struct stat *st, void *data, struct recursor *r)
if (chmod(path, m) < 0) {
weprintf("chmod %s:", path);
ret = 1;
} else if (!(r->flags & NODIRS) && st && S_ISDIR(st->st_mode)) {
} else if (st && S_ISDIR(st->st_mode)) {
recurse(path, NULL, r);
}
}
@@ -31,7 +31,8 @@ usage(void)
int
main(int argc, char *argv[])
{
struct recursor r = { .fn = chmodr, .hist = NULL, .depth = 0, .follow = 'P', .flags = NODIRS};
struct recursor r = { .fn = chmodr, .hist = NULL, .depth = 0, .maxdepth = 1,
.follow = 'P', .flags = 0 };
size_t i;
argv0 = argv[0], argc--, argv++;
@@ -42,7 +43,7 @@ main(int argc, char *argv[])
for (i = 1; (*argv)[i]; i++) {
switch ((*argv)[i]) {
case 'R':
r.flags &= ~NODIRS;
r.maxdepth = 0;
break;
case 'H':
case 'L':