about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-10-12 16:36:41 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-10-12 16:36:41 +0200
commit8a11cc1f6be91c64c9805576d30d1de9d6505dfc (patch)
tree026891fb4fddad8d905abb46c3b8c5483cd61bf3
parentfd6b6873a5fac960a8085d75f2c9d4316a1cabb5 (diff)
downloadxe-8a11cc1f6be91c64c9805576d30d1de9d6505dfc.tar.gz
xe-8a11cc1f6be91c64c9805576d30d1de9d6505dfc.tar.xz
xe-8a11cc1f6be91c64c9805576d30d1de9d6505dfc.zip
perc_match: patterns with ** match against full path too
-rw-r--r--xe.14
-rw-r--r--xe.c4
2 files changed, 5 insertions, 3 deletions
diff --git a/xe.1 b/xe.1
index a7769eb..9661c73 100644
--- a/xe.1
+++ b/xe.1
@@ -139,7 +139,9 @@ is regarded as a pattern,
 see
 .Sx PERCENT RULES
 below.
-Patterns without a slash are matched against the basenames only.
+Patterns without a slash (or
+.Sq Li \&*\&* )
+are matched against the basenames only.
 .Pp
 Multiple runs of patterns and commands are separated by
 .Sq Li \&+ .
diff --git a/xe.c b/xe.c
index 7e75a57..000c0b3 100644
--- a/xe.c
+++ b/xe.c
@@ -493,7 +493,7 @@ perc(char *pat, char *str, int lvl)
 int
 perc_match(char *pat, char *arg)
 {
-	if (!strchr(pat, '/')) {
+	if (!strchr(pat, '/') && !strstr(pat, "**")) {
 		char *d = strrchr(arg, '/');
 		if (d)
 			arg = d + 1;
@@ -515,7 +515,7 @@ perc_subst(char *pat, char *base, char *arg)
 	if (strcmp(arg, replace) == 0)
 		return base;
 
-	if (!strchr(pat, '/')) {
+	if (!strchr(pat, '/') && !strstr(pat, "**")) {
 		char *d = strrchr(base, '/');
 		if (d)
 			base = d + 1;