main: Refactor __is_redirection

Fixes #942.
This commit is contained in:
Matthew Martin
2024-01-06 12:33:41 -06:00
parent dcc99a8649
commit e0165eaa73
3 changed files with 105 additions and 4 deletions

View File

@@ -254,10 +254,9 @@ _zsh_highlight_main__is_runnable() {
_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 >(...)].
# - is not a numeric glob <->
[[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]] && [[ $1 != *'<'*'-'*'>'* ]]
# - is one of the tokens listed in zshmisc(1)
# - however (z) normalizes ! to |
[[ ${1#[0-9]} == (\<|\<\>|(\>|\>\>)(|\|)|\<\<(|-)|\<\<\<|\<\&|\&\<|(\>|\>\>)\&(|\|)|\&(\>|\>\>)(|\||\!)) ]]
}
# Resolve alias.