Skip to content

Commit 63bcd85

Browse files
committed
'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.
1 parent 4bbd2a3 commit 63bcd85

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

highlighters/main/main-highlighter.zsh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,14 +698,24 @@ _zsh_highlight_main_highlighter_highlight_list()
698698
if (( ! in_redirection )); then
699699
if [[ $this_word == *':sudo_opt:'* ]]; then
700700
if [[ -n $flags_with_argument ]] &&
701-
{ [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]] ||
702-
[[ $arg == '-'[$flags_with_argument] ]] }; then
701+
{
702+
# Trenary
703+
if [[ -n $flags_sans_argument ]]
704+
then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]]
705+
else [[ $arg == '-'[$flags_with_argument] ]]
706+
fi
707+
} then
703708
# Flag that requires an argument
704709
this_word=${this_word//:start:/}
705710
next_word=':sudo_arg:'
706711
elif [[ -n $flags_with_argument ]] &&
707-
{ [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]] ||
708-
[[ $arg == '-'[$flags_with_argument]* ]] }; then
712+
{
713+
# Trenary
714+
if [[ -n $flags_sans_argument ]]
715+
then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]]
716+
else [[ $arg == '-'[$flags_with_argument]* ]]
717+
fi
718+
} then
709719
# Argument attached in the same word
710720
this_word=${this_word//:start:/}
711721
next_word+=':start:'

0 commit comments

Comments
 (0)