Add maxdepth to recurse()
This also makes more sense.
This commit is contained in:
7
chgrp.c
7
chgrp.c
@@ -29,7 +29,7 @@ chgrp(const char *path, struct stat *st, void *data, struct recursor *r)
|
||||
if (st && chownf(path, st->st_uid, gid) < 0) {
|
||||
weprintf("%s %s:", chownf_name, 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);
|
||||
}
|
||||
}
|
||||
@@ -44,14 +44,15 @@ int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct group *gr;
|
||||
struct recursor r = { .fn = chgrp, .hist = NULL, .depth = 0, .follow = 'P', .flags = NODIRS };
|
||||
struct recursor r = { .fn = chgrp, .hist = NULL, .depth = 0, .maxdepth = 1,
|
||||
.follow = 'P', .flags = 0 };
|
||||
|
||||
ARGBEGIN {
|
||||
case 'h':
|
||||
hflag = 1;
|
||||
break;
|
||||
case 'R':
|
||||
r.flags &= ~NODIRS;
|
||||
r.maxdepth = 0;
|
||||
break;
|
||||
case 'H':
|
||||
case 'L':
|
||||
|
Reference in New Issue
Block a user