Skip to content

Commit

Permalink
'main': Test for redirection earlier.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danielshahaf committed Aug 16, 2016
1 parent 6e2ef57 commit 179b8e7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions highlighters/main/main-highlighter.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
#
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 179b8e7

Please sign in to comment.