changeset 1427:0d58119f0bcd draft

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.
author Rob Landley <rob@landley.net>
date Thu, 07 Aug 2014 23:19:18 -0500
parents 23169562c3ee
children e66fb422b78a
files toys/posix/find.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/toys/posix/find.c	Tue Aug 05 23:21:18 2014 -0500
+++ b/toys/posix/find.c	Thu Aug 07 23:19:18 2014 -0500
@@ -342,8 +342,13 @@
           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"))