aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-07-29 11:39:10 -0700
committerRob Landley <rob@landley.net>2020-07-30 03:31:24 -0500
commit70a55cf954ecabb858a12b754f4547bcaf78dc2d (patch)
treebc6eefc3b49ce754cd579bd2daa527bd99261c85 /toys/posix
parentd0584bf09a2cf1f91fd524cf339520b26ee0afa0 (diff)
downloadtoybox-70a55cf954ecabb858a12b754f4547bcaf78dc2d.tar.gz
find: support -type a,b,c.
Fixes #227.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/find.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 9b688d46..47cefb78 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -398,10 +398,19 @@ static int do_find(struct dirtree *new)
} else if (!strcmp(s, "type")) {
if (check) {
int types[] = {S_IFBLK, S_IFCHR, S_IFDIR, S_IFLNK, S_IFIFO,
- S_IFREG, S_IFSOCK}, i = stridx("bcdlpfs", *ss[1]);
-
- if (i<0) error_exit("bad -type '%c'", *ss[1]);
- if ((new->st.st_mode & S_IFMT) != types[i]) test = 0;
+ S_IFREG, S_IFSOCK}, i, match = 0;
+ char *t = ss[1];
+
+ for (; *t; t++) {
+ if (*t == ',') continue;
+ i = stridx("bcdlpfs", *t);
+ if (i<0) error_exit("bad -type '%c'", *t);
+ if ((new->st.st_mode & S_IFMT) == types[i]) {
+ match = 1;
+ break;
+ }
+ }
+ if (!match) test = 0;
}
} else if (strchr("acm", *s)