aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-02-13 09:02:24 -0800
committerRob Landley <rob@landley.net>2019-02-13 13:50:40 -0600
commitfbedc9dd74aeb0331202f9e503316960e32fa879 (patch)
tree4fdecbdbdc597ddb8278eec5cccf172133188790 /toys/posix
parent318e7009e92ede1dfcc49ff1249396fd43757619 (diff)
downloadtoybox-fbedc9dd74aeb0331202f9e503316960e32fa879.tar.gz
find: fix -path/-ipath and add -wholename/-iwholename synonyms.
Plus new tests.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/find.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index e6facb30..bae96db5 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -328,13 +328,14 @@ static int do_find(struct dirtree *new)
// Remaining filters take an argument
} else {
if (!strcmp(s, "name") || !strcmp(s, "iname")
+ || !strcmp(s, "wholename") || !strcmp(s, "iwholename")
|| !strcmp(s, "path") || !strcmp(s, "ipath"))
{
- int i = (*s == 'i');
+ int i = (*s == 'i'), is_path = (s[i] != 'n');
char *arg = ss[1], *path = 0, *name = new ? new->name : arg;
// Handle path expansion and case flattening
- if (new && s[i] == 'p') name = path = dirtree_path(new, 0);
+ if (new && is_path) name = path = dirtree_path(new, 0);
if (i) {
if ((check || !new) && name) name = strlower(name);
if (!new) dlist_add(&TT.argdata, name);
@@ -342,7 +343,7 @@ static int do_find(struct dirtree *new)
}
if (check) {
- test = !fnmatch(arg, name, FNM_PATHNAME*(s[i] == 'p'));
+ test = !fnmatch(arg, name, FNM_PATHNAME*(!is_path));
if (i) free(name);
}
free(path);