about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2018-02-26 21:43:12 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2018-02-26 21:43:12 +0000
commit1d6954bd2f047ed7e6b608eaf40bf0e1c5429b67 (patch)
tree764b0d08c1934f1d237ae827a42c017c7c7909a4
parent14743c0dfdb81a6a4a051921e56a61c3b1e0e664 (diff)
downloadzsh-1d6954bd2f047ed7e6b608eaf40bf0e1c5429b67.tar.gz
zsh-1d6954bd2f047ed7e6b608eaf40bf0e1c5429b67.tar.xz
zsh-1d6954bd2f047ed7e6b608eaf40bf0e1c5429b67.zip
23180: Fix expand-or-complete with ~[...].
The square brackets shouldn't be treated as wildcards.
-rw-r--r--ChangeLog4
-rw-r--r--Src/Zle/zle_tricky.c9
2 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b2054f4f9..c6b48d14a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2018-02-26  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 23180: Src/Zle/zle_tricky.c: Square brackets in dynamic
+	directory expansion shouldn't force expansion in
+	expand-or-complete.
+
 	* Joey Pabalinas: 42401: Src/mem.c: replace malloc with use of
 	realloc to work around crash with gcc using -foptimize-strlen.
 
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index caeef7692..22c381237 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -456,6 +456,7 @@ checkparams(char *p)
 static int
 cmphaswilds(char *str)
 {
+    char *ptr;
     if ((*str == Inbrack || *str == Outbrack) && !str[1])
 	return 0;
 
@@ -465,6 +466,14 @@ cmphaswilds(char *str)
     if (str[0] == '%' && str[1] ==Quest)
 	str += 2;
 
+    /*
+     * In ~[foo], the square brackets are not wild cards.
+     * This test matches the master one in filesubstr().
+     */
+    if (*str == Tilde && str[1] == Inbrack &&
+	(ptr = strchr(str+2, Outbrack)))
+	str = ptr + 1;
+
     for (; *str;) {
 	if (*str == String || *str == Qstring) {
 	    /* A parameter expression. */