Merge remote-tracking branch 'upstream/pr/308' into HEAD

* upstream/pr/308:
  'main': Fix issue #302, "Process substitution misparsed as redirection".
  'main': Factor out common code.  No functional change.
  'main': Add a regression test for issue #302, "Process substitution misparsed as redirection".
This commit is contained in:
Daniel Shahaf
2016-05-13 01:24:01 +00:00
2 changed files with 48 additions and 2 deletions

View File

@@ -93,6 +93,16 @@ _zsh_highlight_main__type() {
LC_ALL=C builtin type -w -- $1 2>/dev/null
}
# Check whether the first argument is a redirection operator token.
# Report result via the exit code.
_zsh_highlight_main__is_redirection() {
# A redirection operator token:
# - starts with an optional single-digit number;
# - then, has a '<' or '>' character;
# - is not a process substitution [<(...) or >(...)].
[[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]]
}
# Main syntax highlighting function.
_zsh_highlight_main_highlighter()
{
@@ -374,7 +384,7 @@ _zsh_highlight_main_highlighter()
else
style=unknown-token
fi
elif [[ $arg == (<0-9>|)(\<|\>)* ]]; then
elif _zsh_highlight_main__is_redirection $arg; then
# A '<' or '>', possibly followed by a digit
style=redirection
(( in_redirection=2 ))
@@ -444,7 +454,7 @@ _zsh_highlight_main_highlighter()
else
style=unknown-token
fi
elif [[ $arg == (<0-9>|)(\<|\>)* ]]; then
elif _zsh_highlight_main__is_redirection $arg; then
style=redirection
(( in_redirection=2 ))
else