mirror of
git://git.code.sf.net/p/zsh/code
synced 2026-01-06 09:41:07 +01:00
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.
This commit is contained in:
parent
15aa99b0fe
commit
e86720190e
2 changed files with 16 additions and 1 deletions
|
|
@ -1,3 +1,9 @@
|
|||
2015-05-15 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 35131: Src/pattern.c: "[]" in a pattern is treated as an empty
|
||||
character set (matching nothing) if there are no more active "]"
|
||||
is in the pattern.
|
||||
|
||||
2015-05-14 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 35139: Completion/Zsh/Context/_brace_parameter: add (b) flag
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue