main: Recognize more redirection and array assignment parse errors

() ) } are invalid as a redirection target.
() } are invalid in an array assignment.
This commit is contained in:
Matthew Martin 2018-10-01 18:18:52 -04:00
parent 2f03b6d704
commit dea05e44e6

View file

@ -795,6 +795,8 @@ _zsh_highlight_main_highlighter_highlight_list()
style=assign style=assign
in_array_assignment=false in_array_assignment=false
next_word+=':start:' next_word+=':start:'
elif (( in_redirection )); then
style=unknown-token
else else
if _zsh_highlight_main__stack_pop 'S'; then if _zsh_highlight_main__stack_pop 'S'; then
REPLY=$start_pos REPLY=$start_pos
@ -804,11 +806,15 @@ _zsh_highlight_main_highlighter_highlight_list()
_zsh_highlight_main__stack_pop 'R' reserved-word _zsh_highlight_main__stack_pop 'R' reserved-word
fi;; fi;;
$'\x28\x29') # possibly a function definition $'\x28\x29') # possibly a function definition
if [[ $zsyh_user_options[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word if (( in_redirection )) || $in_array_assignment; then
then style=unknown-token
next_word+=':start:' else
if [[ $zsyh_user_options[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
then
next_word+=':start:'
fi
style=reserved-word
fi fi
style=reserved-word
;; ;;
*) if false; then *) if false; then
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
@ -816,9 +822,13 @@ _zsh_highlight_main_highlighter_highlight_list()
# #
# Additionally, `tt(})' is recognized in any position if neither the # Additionally, `tt(})' is recognized in any position if neither the
# tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set. # tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.
_zsh_highlight_main__stack_pop 'Y' reserved-word if (( in_redirection )) || $in_array_assignment; then
if [[ $style == reserved-word ]]; then style=unknown-token
next_word+=':always:' else
_zsh_highlight_main__stack_pop 'Y' reserved-word
if [[ $style == reserved-word ]]; then
next_word+=':always:'
fi
fi fi
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
style=history-expansion style=history-expansion