[git commit master] find: fix -name matching for dotfiles. -1 byte

Denys Vlasenko vda.linux at googlemail.com
Mon Apr 26 07:54:04 UTC 2010


commit: http://git.busybox.net/busybox/commit/?id=9138817a27068073a565d915d10301ca00e79659
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 findutils/find.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/findutils/find.c b/findutils/find.c
index 0b06938..30fb03d 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -198,14 +198,19 @@ static int exec_actions(action ***appp, const char *fileName, const struct stat
 ACTF(name)
 {
 	const char *tmp = bb_basename(fileName);
-	if (tmp != fileName && !*tmp) { /* "foo/bar/". Oh no... go back to 'b' */
+	if (tmp != fileName && *tmp == '\0') {
+		/* "foo/bar/". Oh no... go back to 'b' */
 		tmp--;
 		while (tmp != fileName && *--tmp != '/')
 			continue;
 		if (*tmp == '/')
 			tmp++;
 	}
-	return fnmatch(ap->pattern, tmp, FNM_PERIOD | (ap->iname ? FNM_CASEFOLD : 0)) == 0;
+	/* Was using FNM_PERIOD flag too,
+	 * but somewhere between 4.1.20 and 4.4.0 GNU find stopped using it.
+	 * find -name '*foo' should match .foo too:
+	 */
+	return fnmatch(ap->pattern, tmp, (ap->iname ? FNM_CASEFOLD : 0)) == 0;
 }
 
 #if ENABLE_FEATURE_FIND_PATH
-- 
1.6.3.3



More information about the busybox-cvs mailing list