From 179b8e753fa572f2d42003954b04c23cdc63d646 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 16 Aug 2016 13:27:36 +0000 Subject: [PATCH] 'main': Test for redirection earlier. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a prerequisite for the next commit. The incumbent code was wrong: the test of $in_redirection in the first hunk would never have seen «(( in_redirection == 2 ))». That had no visible effect since options to sudo don't look like redirection operators. --- highlighters/main/main-highlighter.zsh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 47e43e7..ade7907 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -331,6 +331,11 @@ _zsh_highlight_main_highlighter() continue fi + if _zsh_highlight_main__is_redirection $arg ; then + # A '<' or '>', possibly followed by a digit + in_redirection=2 + fi + # Parse the sudo command line if (( ! in_redirection )); then if [[ $this_word == *':sudo_opt:'* ]]; then @@ -432,10 +437,8 @@ _zsh_highlight_main_highlighter() else style=unknown-token fi - elif _zsh_highlight_main__is_redirection $arg; then - # A '<' or '>', possibly followed by a digit + elif (( in_redirection == 2 )); then style=redirection - (( in_redirection=2 )) elif [[ $arg[1,2] == '((' ]]; then # Arithmetic evaluation. # @@ -509,9 +512,8 @@ _zsh_highlight_main_highlighter() else style=unknown-token fi - elif _zsh_highlight_main__is_redirection $arg; then + elif (( in_redirection == 2 )); then style=redirection - (( in_redirection=2 )) else if _zsh_highlight_main_highlighter_check_path; then style=$REPLY