From 31276c1b64094f3919bb3595c547b66b222a17c6 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Wed, 10 Oct 2018 23:02:33 -0500 Subject: [PATCH] main: Avoid empty character classes Avoids an error in pre-5.0.8: bad pattern: -[]# --- highlighters/main/main-highlighter.zsh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index e5f879c..fceddc4 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -608,17 +608,20 @@ _zsh_highlight_main_highlighter_highlight_list() if (( ! in_redirection )); then if [[ $this_word == *':sudo_opt:'* ]]; then if [[ -n $flags_with_argument ]] && - [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]]; then + { [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]] || + [[ $arg == '-'[$flags_with_argument] ]] }; then # Flag that requires an argument this_word=${this_word//:start:/} next_word=':sudo_arg:' elif [[ -n $flags_with_argument ]] && - [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]]; then + { [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]] || + [[ $arg == '-'[$flags_with_argument]* ]] }; then # Argument attached in the same word this_word=${this_word//:start:/} next_word+=':start:' next_word+=':sudo_opt:' - elif [[ $arg == '-'[$flags_sans_argument]# ]]; then + elif [[ -n $flags_sans_argument ]] && + [[ $arg == '-'[$flags_sans_argument]# ]]; then # Flag that requires no argument this_word=:sudo_opt: next_word+=':start:'