'main': Test for redirection earlier.

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.
This commit is contained in:
Daniel Shahaf 2016-08-16 13:27:36 +00:00
parent 6e2ef574c8
commit 179b8e753f

View file

@ -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