'main': Highlight 'sudo' correctly when it's not installed.
No test because _zsh_highlight_main__type() falls back to 'type -w' which runs 'rehash' implicitly, so on systems where 'sudo' is installed it's not possible to simulate its being absent. Test by forcing _zsh_highlight_main__type() to return 'none' when the argument is [[ $1 == 'sudo' ]], and: (1) Run 'make test' and confirm that all tests either pass, or fail and the first test point that fails is one that expects "sudo" at command position to be highlighted as 'command'; (2) In an interactive zsh, 'sudo' at command position is highlighted as an error.
This commit is contained in:
parent
c13ee4cf88
commit
26a82113b0
|
@ -147,6 +147,7 @@ _zsh_highlight_main__type() {
|
|||
fi
|
||||
fi
|
||||
if ! (( $+REPLY )); then
|
||||
# Note that 'type -w' will run 'rehash' implicitly.
|
||||
REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }"
|
||||
fi
|
||||
if (( $+_zsh_highlight_main__command_type_cache )); then
|
||||
|
@ -457,7 +458,7 @@ _zsh_highlight_highlighter_main_paint()
|
|||
elif [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word
|
||||
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then
|
||||
style=precommand
|
||||
elif [[ "$arg" = "sudo" ]]; then
|
||||
elif [[ "$arg" = "sudo" ]] && { _zsh_highlight_main__type sudo; [[ -n $REPLY && $REPLY != "none" ]] }; then
|
||||
style=precommand
|
||||
next_word=${next_word//:regular:/}
|
||||
next_word+=':sudo_opt:'
|
||||
|
|
Loading…
Reference in New Issue
Block a user