aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-08-29 13:44:59 -0700
committerRob Landley <rob@landley.net>2019-08-30 13:07:57 -0500
commit3437f30ae9a24740bf3e9dd2b5db7482a5c1dfb8 (patch)
treeb6db868ba899d338bc34e11ef7fc8469821aba0b /toys/posix
parent0222d5957329eb575ef20ae7a00170bcab70b662 (diff)
downloadtoybox-3437f30ae9a24740bf3e9dd2b5db7482a5c1dfb8.tar.gz
find: fix -name corner case.
This fixes the case where someone's done something (weird) like: find src/*.c -name foo.c Previously the match would fail because one side of the comparison was already a path.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/find.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 58a6f88d..02fdf3c4 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -368,7 +368,8 @@ static int do_find(struct dirtree *new)
}
if (check) {
- test = !fnmatch(arg, name, FNM_PATHNAME*(!is_path));
+ test = !fnmatch(arg, is_path ? name : basename(name),
+ FNM_PATHNAME*(!is_path));
if (i) free(name);
}
free(path);