diff options
author | Rob Landley <rob@landley.net> | 2014-08-07 23:19:18 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-08-07 23:19:18 -0500 |
commit | c572530223ddad725e0f7606bf4b898d8f95f640 (patch) | |
tree | 0a2ab1c359358456e60cdf4390809f9610ff9a85 | |
parent | c39a337101de8613e71c5c474feb54297cce5eaa (diff) | |
download | toybox-c572530223ddad725e0f7606bf4b898d8f95f640.tar.gz |
Fix -mindepth and -maxdepth to not drill down into excluded directories.
The fact other implementations don't implement "! -mindepth" doesn't mean we can't. Also, find uses +N, N, -N for everything else but this extension doesn't. Also, -depth already had a definition and this has nothing to do with that. It's a poorly thought-out extension, is what I'm saying.
-rw-r--r-- | toys/posix/find.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c index 051c2702..a5a95d96 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -342,8 +342,13 @@ static int do_find(struct dirtree *new) int i = 0, d = atolx(ss[1]); while ((dt = dt->parent)) i++; - - test = s[1] == 'i' ? i >= d : i <= d; + if (s[1] == 'i') { + test = i >= d; + if (i == d && not) recurse = 0; + } else { + test = i <= d; + if (i == d && !not) recurse = 0; + } } } else if (!strcmp(s, "user") || !strcmp(s, "group") || !strcmp(s, "newer")) |