summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-05-15 09:35:24 +0100
committerPeter Stephenson <pws@zsh.org>2015-05-15 09:35:24 +0100
commite86720190efc6550086e6a733394cb393cd0da4d (patch)
tree37564de9501548e085d82426bded49ae52d74a79 /Src
parent15aa99b0fe987920df8a06a7996d8398e75d3b2a (diff)
downloadzsh-e86720190efc6550086e6a733394cb393cd0da4d.tar.gz
zsh-e86720190efc6550086e6a733394cb393cd0da4d.tar.xz
zsh-e86720190efc6550086e6a733394cb393cd0da4d.zip
35131: allow "[]" to match empty character set.
This only works if there's no further "]" in the pattern,
since if there is the first "]" has to match a literal character.
Diffstat (limited to 'Src')
-rw-r--r--Src/pattern.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Src/pattern.c b/Src/pattern.c
index 05dcb2943..4e5e8a110 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -1405,7 +1405,16 @@ patcomppiece(int *flagp, int paren)
 		starter = patnode(P_ANYBUT);
 	    } else
 		starter = patnode(P_ANYOF);
-	    if (*patparse == Outbrack) {
+	    /*
+	     * []...] means match a "]" or other included characters.
+	     * However, to be a bit helpful and for compatibility
+	     * with other shells, don't take in that sense if
+	     * there's no further "]".  That's still imperfect,
+	     * but it's all we can do --- we're required to
+	     * treat [$var]*[$var]with empty var as [ ... ]
+	     * containing "]*[".
+	     */
+	    if (*patparse == Outbrack && strchr(patparse+1, Outbrack)) {
 		patparse++;
 		patadd(NULL, ']', 1, PA_NOALIGN);
 	    }