Просмотр исходного кода

'main': Don't use «foo && bar || baz» where a trenary is more appropriate.

This prevents the baz pattern match from being attempted whenever the
bar pattern match was tried and failed.
pull/599/merge
Daniel Shahaf 4 лет назад
Родитель
Сommit
63bcd85dfa
1 измененных файлов: 14 добавлений и 4 удалений
  1. +14
    -4
      highlighters/main/main-highlighter.zsh

+ 14
- 4
highlighters/main/main-highlighter.zsh Просмотреть файл

@ -698,14 +698,24 @@ _zsh_highlight_main_highlighter_highlight_list()
if (( ! in_redirection )); then
if [[ $this_word == *':sudo_opt:'* ]]; then
if [[ -n $flags_with_argument ]] &&
{ [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]] ||
[[ $arg == '-'[$flags_with_argument] ]] }; then
{
# Trenary
if [[ -n $flags_sans_argument ]]
then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]]
else [[ $arg == '-'[$flags_with_argument] ]]
fi
} then
# Flag that requires an argument
this_word=${this_word//:start:/}
next_word=':sudo_arg:'
elif [[ -n $flags_with_argument ]] &&
{ [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]] ||
[[ $arg == '-'[$flags_with_argument]* ]] }; then
{
# Trenary
if [[ -n $flags_sans_argument ]]
then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]]
else [[ $arg == '-'[$flags_with_argument]* ]]
fi
} then
# Argument attached in the same word
this_word=${this_word//:start:/}
next_word+=':start:'

Загрузка…
Отмена
Сохранить