highlight array assignments of the form x[y]=...

This code is more lenient than bash.  Examples:

    $ x[y[]=
    zsh: no matches found: x[y[]=
    $ x[][]=
    zsh: no matches found: x[][]=

The proper solution is to look inside the [...] and make sure that all
unescaped/unquoted square brackes are matched, but that is a heck of
a lot more complicated than this simple 8-character patch.
This commit is contained in:
Mark Lodato 2013-10-30 00:46:17 -04:00
parent c62cb54e9d
commit 441f1a8aad

View File

@ -153,7 +153,7 @@ _zsh_highlight_main_highlighter()
_zsh_highlight_main_highlighter_check_assign() _zsh_highlight_main_highlighter_check_assign()
{ {
setopt localoptions extended_glob setopt localoptions extended_glob
[[ $arg == [[:alpha:]_]([[:alnum:]_])#=* ]] [[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])=* ]]
} }
# Check if the argument is a path. # Check if the argument is a path.