From c62cb54e9db82a64aa0975f84c2ab46a056e965e Mon Sep 17 00:00:00 2001 From: Mark Lodato Date: Wed, 30 Oct 2013 00:00:16 -0400 Subject: [PATCH 1/2] do not remove quotes when checking assignments Zsh does not allow the variable name or the equals sign to be quoted or escaped. The previous code incorrectly highlighted the following examples as assignments: $ 'x=y' zsh: command not found: x=y $ x\=y zsh: command not found: x=y $ "x"=y zsh: command not found: x=y $ \x=y zsh: command not found: x=y --- highlighters/main/main-highlighter.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index f70a286..e2abcc1 100755 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -153,7 +153,7 @@ _zsh_highlight_main_highlighter() _zsh_highlight_main_highlighter_check_assign() { setopt localoptions extended_glob - [[ ${(Q)arg} == [[:alpha:]_]([[:alnum:]_])#=* ]] + [[ $arg == [[:alpha:]_]([[:alnum:]_])#=* ]] } # Check if the argument is a path. From 441f1a8aad75b6f3e80cdd05e2307896e162dd82 Mon Sep 17 00:00:00 2001 From: Mark Lodato Date: Wed, 30 Oct 2013 00:46:17 -0400 Subject: [PATCH 2/2] 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. --- highlighters/main/main-highlighter.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index e2abcc1..f69e656 100755 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -153,7 +153,7 @@ _zsh_highlight_main_highlighter() _zsh_highlight_main_highlighter_check_assign() { setopt localoptions extended_glob - [[ $arg == [[:alpha:]_]([[:alnum:]_])#=* ]] + [[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[*\])=* ]] } # Check if the argument is a path.