summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/pattern.c14
-rw-r--r--Src/zsh.h6
2 files changed, 15 insertions, 5 deletions
diff --git a/Src/pattern.c b/Src/pattern.c
index a7ef12573..b79c3b444 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -1265,12 +1265,18 @@ patcomppiece(int *flagp, int paren)
* the character following is an end-of-segment character. Thus
* tildes are not special if there is nothing following to
* be excluded.
+ *
+ * Don't look for X()-style kshglobs at this point; we've
+ * checked above for the case with parentheses and we don't
+ * want to match without parentheses.
*/
- if (kshchar || (memchr(zpc_special, *patparse, ZPC_COUNT) &&
- (*patparse != zpc_special[ZPC_TILDE] ||
- patparse[1] == '/' ||
- !memchr(zpc_special, patparse[1], ZPC_SEG_COUNT))))
+ if (kshchar ||
+ (memchr(zpc_special, *patparse, ZPC_NO_KSH_GLOB) &&
+ (*patparse != zpc_special[ZPC_TILDE] ||
+ patparse[1] == '/' ||
+ !memchr(zpc_special, patparse[1], ZPC_SEG_COUNT)))) {
break;
+ }
}
/* Remember the previous character for backtracking */
diff --git a/Src/zsh.h b/Src/zsh.h
index a935d23ad..c86d2a62c 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1417,7 +1417,11 @@ enum zpc_chars {
ZPC_HAT, /* ^ for exclusion (extended glob) */
ZPC_HASH, /* # for repetition (extended glob) */
ZPC_BNULLKEEP, /* Special backslashed null not removed */
- ZPC_KSH_QUEST, /* ? for ?(...) in KSH_GLOB */
+ /*
+ * These characters are only valid before a parenthesis
+ */
+ ZPC_NO_KSH_GLOB,
+ ZPC_KSH_QUEST = ZPC_NO_KSH_GLOB, /* ? for ?(...) in KSH_GLOB */
ZPC_KSH_STAR, /* * for *(...) in KSH_GLOB */
ZPC_KSH_PLUS, /* + for +(...) in KSH_GLOB */
ZPC_KSH_BANG, /* ! for !(...) in KSH_GLOB */