From 784a5dc35b38aa23f651da70adcf4e72f31e4c30 Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Tue, 5 Nov 2013 00:50:20 +0100 Subject: [PATCH] protect alias expansion from interpreting aliases as options If one defines aliases like `++` the alias builtin tries to interprete these as options so they have to be protected like this alias -- ++=true The same goes for a call to `alias` in order to expand the alias again. --- highlighters/main/main-highlighter.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index f70a286..b2e942b 100755 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -63,7 +63,7 @@ _zsh_highlight_main_highlighter_predicate() # Main syntax highlighting function. _zsh_highlight_main_highlighter() { - emulate -L zsh + emulate -L zsh setopt localoptions extendedglob bareglobqual local start_pos=0 end_pos highlight_glob=true new_expression=true arg style typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR @@ -97,7 +97,7 @@ _zsh_highlight_main_highlighter() case $res in *': reserved') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];; *': alias') style=$ZSH_HIGHLIGHT_STYLES[alias] - local aliased_command="${"$(alias $arg)"#*=}" + local aliased_command="${"$(alias -- $arg)"#*=}" [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$aliased_command"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS+=($arg) ;; *': builtin') style=$ZSH_HIGHLIGHT_STYLES[builtin];;