@@ -312,7 +312,7 @@ _zsh_highlight_highlighter_main_paint()
312312 local flags_sans_argument
313313 # $flags_solo is a set of letters, corresponding to option letters that, if
314314 # present, mean the precommand will not be acting as a precommand, i.e., will
315- # not be followed by a : start: word.
315+ # not be followed by an 's' ( start) word.
316316 local flags_solo
317317 # $_zsh_highlight_main__precommand_options maps precommand name to values of
318318 # $flags_with_argument, $flags_sans_argument, and flags_solo for that precommand,
@@ -451,25 +451,25 @@ _zsh_highlight_main_highlighter_highlight_list()
451451 # State machine
452452 #
453453 # The states are:
454- # - :start: Command word
455- # - :start_of_pipeline: Start of a 'pipeline' as defined in zshmisc(1).
456- # Only valid when :start: is present
457- # - :sudo_opt: A leading-dash option to a precommand, whether it takes an
458- # argument or not. (Example: sudo's "-u" or "-i".)
459- # - :sudo_arg: The argument to a precommand's leading-dash option,
460- # when given as a separate word; i.e., "foo" in "-u foo" (two
461- # words) but not in "-ufoo" (one word).
462- # Note: :sudo_opt: and :sudo_arg: are used for any precommand
463- # declared in ${_zsh_highlight_main__precommand_options}, not just
464- # for sudo(8). The naming is historical.
465- # - :regular: "Not a command word", and command delimiters are permitted.
466- # Mainly used to detect premature termination of commands.
467- # - :always: The word 'always' in the «{ foo } always { bar }» syntax.
454+ # - s Command word
455+ # - p Start of a 'pipeline' as defined in zshmisc(1).
456+ # Only valid when 's' is present
457+ # - o A leading-dash option to a precommand, whether it takes an
458+ # argument or not. (Example: sudo's "-u" or "-i".)
459+ # - a The argument to a precommand's leading-dash option,
460+ # when given as a separate word; i.e., "foo" in "-u foo" (two
461+ # words) but not in "-ufoo" (one word).
462+ # Note: 'o' and 'a' are used for any precommand
463+ # declared in ${_zsh_highlight_main__precommand_options}, not just
464+ # for sudo(8). The naming is historical.
465+ # - r "Not a command word", and command delimiters are permitted.
466+ # Mainly used to detect premature termination of commands.
467+ # - w The word 'always' in the «{ foo } always { bar }» syntax.
468468 #
469469 # When the kind of a word is not yet known, $this_word / $next_word may contain
470470 # multiple states. For example, after "sudo -i", the next word may be either
471- # another --flag or a command name, hence the state would include both ':start: '
472- # and ':sudo_opt: '.
471+ # another --flag or a command name, hence the state would include both 's '
472+ # and 'o '.
473473 #
474474 # The tokens are always added with both leading and trailing colons to serve as
475475 # word delimiters (an improvised array); [[ $x == *':foo:'* ]] and x=${x//:foo:/}
@@ -497,7 +497,7 @@ _zsh_highlight_main_highlighter_highlight_list()
497497 # - parameter elision in command position
498498 # - 'repeat' loops
499499 #
500- local this_word next_word=' :start::start_of_pipeline: '
500+ local this_word next_word=' sp '
501501 integer in_redirection
502502 # Processing buffer
503503 local proc_buf=" $buf "
@@ -538,7 +538,7 @@ _zsh_highlight_main_highlighter_highlight_list()
538538 # Initialize this_word and next_word.
539539 if (( in_redirection == 0 )) ; then
540540 this_word=$next_word
541- next_word=' :regular: '
541+ next_word=' r '
542542 elif (( ! in_param )) ; then
543543 # Stall $next_word.
544544 (( -- in_redirection ))
@@ -552,7 +552,7 @@ _zsh_highlight_main_highlighter_highlight_list()
552552 # $saw_assignment boolean flag for "was preceded by an assignment"
553553 #
554554 style=unknown-token
555- if [[ $this_word == * ' :start: ' * ]]; then
555+ if [[ $this_word == * ' s ' * ]]; then
556556 in_array_assignment=false
557557 if [[ $arg == ' noglob' ]]; then
558558 highlight_glob=false
@@ -596,7 +596,7 @@ _zsh_highlight_main_highlighter_highlight_list()
596596 #
597597 # We use the (Z+c+) flag so the entire comment is presented as one token in $arg.
598598 if [[ $zsyh_user_options [interactivecomments] == on && $arg [1] == $histchars [3] ]]; then
599- if [[ $this_word == * (' :regular: ' | ' :start: ' )* ]]; then
599+ if [[ $this_word == * (' r ' | ' s ' )* ]]; then
600600 style=comment
601601 else
602602 style=unknown-token # prematurely terminated
@@ -607,7 +607,7 @@ _zsh_highlight_main_highlighter_highlight_list()
607607 continue
608608 fi
609609
610- if [[ $this_word == * ' :start: ' * ]] && ! (( in_redirection )) ; then
610+ if [[ $this_word == * ' s ' * ]] && ! (( in_redirection )) ; then
611611 # Expand aliases.
612612 # An alias is ineligible for expansion while it's being expanded (see #652/#653).
613613 _zsh_highlight_main__type " $arg " " $(( ! ${+seen_alias[$arg]} )) "
@@ -690,7 +690,7 @@ _zsh_highlight_main_highlighter_highlight_list()
690690
691691 # Parse the sudo command line
692692 if (( ! in_redirection )) ; then
693- if [[ $this_word == * ' :sudo_opt: ' * ]]; then
693+ if [[ $this_word == * ' o ' * ]]; then
694694 if [[ -n $flags_with_argument ]] &&
695695 {
696696 # Trenary
@@ -700,8 +700,8 @@ _zsh_highlight_main_highlighter_highlight_list()
700700 fi
701701 } then
702702 # Flag that requires an argument
703- this_word= ${this_word//: start : / }
704- next_word= ' :sudo_arg: '
703+ this_word= ${this_word// s / }
704+ next_word= ' a '
705705 elif [[ -n $flags_with_argument ]] &&
706706 {
707707 # Trenary
@@ -711,15 +711,15 @@ _zsh_highlight_main_highlighter_highlight_list()
711711 fi
712712 } then
713713 # Argument attached in the same word
714- this_word= ${this_word//: start : / }
715- next_word+= ' :start: '
716- next_word+= ' :sudo_opt: '
714+ this_word= ${this_word// s / }
715+ next_word+= ' s '
716+ next_word+= ' o '
717717 elif [[ -n $flags_sans_argument ]] &&
718718 [[ $arg == ' -' [$flags_sans_argument ]# ]]; then
719719 # Flag that requires no argument
720- this_word= ' :sudo_opt: '
721- next_word+= ' :start: '
722- next_word+= ' :sudo_opt: '
720+ this_word= ' o '
721+ next_word+= ' s '
722+ next_word+= ' o '
723723 elif [[ -n $flags_solo ]] &&
724724 {
725725 # Trenary
@@ -729,8 +729,8 @@ _zsh_highlight_main_highlighter_highlight_list()
729729 fi
730730 } then
731731 # Solo flags
732- this_word= ' :sudo_opt: '
733- next_word= ' :regular: ' # no :start: , nor :sudo_opt: since we don't know whether the solo flag takes an argument or not
732+ this_word= ' o '
733+ next_word= ' r ' # no 's' , nor 'o' since we don't know whether the solo flag takes an argument or not
734734 elif [[ $arg == ' -' * ]]; then
735735 # Unknown flag. We don't know whether it takes an argument or not,
736736 # so modify $next_word as we do for flags that require no argument.
@@ -739,18 +739,18 @@ _zsh_highlight_main_highlighter_highlight_list()
739739 # argument we'll highlight the command word correctly if the argument
740740 # was given in the same shell word as the flag (as in '-uphy1729' or
741741 # '--user=phy1729' without spaces).
742- this_word= ' :sudo_opt: '
743- next_word+= ' :start: '
744- next_word+= ' :sudo_opt: '
742+ this_word= ' o '
743+ next_word+= ' s '
744+ next_word+= ' o '
745745 else
746746 # Not an option flag; nothing to do. (If the command line is
747- # syntactically valid, ${this_word//:sudo_opt: /} should be
747+ # syntactically valid, ${this_word//o /} should be
748748 # non-empty now.)
749- this_word= ${this_word//: sudo_opt : / }
749+ this_word= ${this_word// o / }
750750 fi
751- elif [[ $this_word == * ' :sudo_arg: ' * ]]; then
752- next_word+= ' :sudo_opt: '
753- next_word+= ' :start: '
751+ elif [[ $this_word == * ' a ' * ]]; then
752+ next_word+= ' o '
753+ next_word+= ' s '
754754 fi
755755 fi
756756
@@ -773,11 +773,11 @@ _zsh_highlight_main_highlighter_highlight_list()
773773 # Other command separators aren't allowed.
774774 (* ) style=unknown-token;;
775775 esac
776- elif [[ $this_word == * ' :regular: ' * ]]; then
776+ elif [[ $this_word == * ' r ' * ]]; then
777777 style=commandseparator
778- elif [[ $this_word == * ' :start: ' * ]] && [[ $arg == $' \n ' ]]; then
778+ elif [[ $this_word == * ' s ' * ]] && [[ $arg == $' \n ' ]]; then
779779 style=commandseparator
780- elif [[ $this_word == * ' :start: ' * ]] && [[ $arg == ' ;' ]] && (( in_alias )) ; then
780+ elif [[ $this_word == * ' s ' * ]] && [[ $arg == ' ;' ]] && (( in_alias )) ; then
781781 style=commandseparator
782782 else
783783 # Empty commands (semicolon follows nothing) are valid syntax.
@@ -794,26 +794,26 @@ _zsh_highlight_main_highlighter_highlight_list()
794794 # Second, determine the style of next_word.
795795 if [[ $arg == $' \n ' ]] && $in_array_assignment ; then
796796 # literal newline inside an array assignment
797- next_word=' :regular: '
797+ next_word=' r '
798798 elif [[ $arg == ' ;' ]] && $in_array_assignment ; then
799799 # literal semicolon inside an array assignment
800- next_word=' :regular: '
800+ next_word=' r '
801801 else
802- next_word=' :start: '
802+ next_word=' s '
803803 highlight_glob=true
804804 saw_assignment=false
805805 if [[ $arg != ' |' && $arg != ' |&' ]]; then
806- next_word+=' :start_of_pipeline: '
806+ next_word+=' p '
807807 fi
808808 fi
809809
810- elif ! (( in_redirection)) && [[ $this_word == * ' :always: ' * && $arg == ' always' ]]; then
810+ elif ! (( in_redirection)) && [[ $this_word == * ' w ' * && $arg == ' always' ]]; then
811811 # try-always construct
812812 style=reserved-word # de facto a reserved word, although not de jure
813813 highlight_glob=true
814814 saw_assignment=false
815- next_word=' :start::start_of_pipeline: ' # only left brace is allowed, apparently
816- elif ! (( in_redirection)) && [[ $this_word == * ' :start: ' * ]]; then # $arg is the command word
815+ next_word=' sp ' # only left brace is allowed, apparently
816+ elif ! (( in_redirection)) && [[ $this_word == * ' s ' * ]]; then # $arg is the command word
817817 if (( ${+_zsh_highlight_main__precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg ; then
818818 style=precommand
819819 () {
@@ -822,12 +822,12 @@ _zsh_highlight_main_highlighter_highlight_list()
822822 flags_sans_argument=$2
823823 flags_solo=$3
824824 }
825- next_word=${next_word//: regular : / }
826- next_word+=' :sudo_opt: '
827- next_word+=' :start: '
825+ next_word=${next_word// r / }
826+ next_word+=' o '
827+ next_word+=' s '
828828 if [[ $arg == ' exec' ]]; then
829829 # To allow "exec 2>&1;" where there's no command word
830- next_word+=' :regular: '
830+ next_word+=' r '
831831 fi
832832 else
833833 case $res in
@@ -836,8 +836,8 @@ _zsh_highlight_main_highlighter_highlight_list()
836836 # Match braces and handle special cases.
837837 case $arg in
838838 (time|nocorrect)
839- next_word=${next_word//: regular : / }
840- next_word+=' :start: '
839+ next_word=${next_word// r / }
840+ next_word+=' s '
841841 ;;
842842 ($' \x7b ' )
843843 braces_stack=' Y' " $braces_stack "
@@ -846,7 +846,7 @@ _zsh_highlight_main_highlighter_highlight_list()
846846 # We're at command word, so no need to check right_brace_is_recognised_everywhere
847847 _zsh_highlight_main__stack_pop ' Y' reserved-word
848848 if [[ $style == reserved-word ]]; then
849- next_word+=' :always: '
849+ next_word+=' w '
850850 fi
851851 ;;
852852 ($' \x5b\x5b ' )
@@ -897,10 +897,10 @@ _zsh_highlight_main_highlighter_highlight_list()
897897 # or a command separator (`repeat 2; ls` or `repeat 2; do ls; done`).
898898 #
899899 # The repeat-count word will be handled like a redirection target.
900- this_word=' :start::regular: '
900+ this_word=' sr '
901901 ;;
902902 (' !' )
903- if [[ $this_word != * ' :start_of_pipeline: ' * ]]; then
903+ if [[ $this_word != * ' p ' * ]]; then
904904 style=unknown-token
905905 else
906906 # '!' reserved word at start of pipeline; style already set above
@@ -935,9 +935,9 @@ _zsh_highlight_main_highlighter_highlight_list()
935935 # assignment to a scalar parameter.
936936 # (For array assignments, the command doesn't start until the ")" token.)
937937 #
938- # Discard :start_of_pipeline: , if present, as '!' is not valid
938+ # Discard 'p' , if present, as '!' is not valid
939939 # after assignments.
940- next_word+=' :start: '
940+ next_word+=' s '
941941 if (( i <= $# arg )) ; then
942942 () {
943943 local highlight_glob=false
@@ -1003,7 +1003,7 @@ _zsh_highlight_main_highlighter_highlight_list()
10031003 esac
10041004 fi
10051005 if [[ -n ${(M)_zsh_highlight_main__tokens_control_flow:# " $arg " } ]]; then
1006- next_word=' :start::start_of_pipeline: '
1006+ next_word=' sp '
10071007 fi
10081008 elif _zsh_highlight_main__is_global_alias " $arg " ; then # $arg is a global alias that isn't in command position
10091009 style=global-alias
@@ -1015,7 +1015,7 @@ _zsh_highlight_main_highlighter_highlight_list()
10151015 _zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
10161016 _zsh_highlight_main_add_region_highlight $start_pos $end_pos reserved-word
10171017 in_array_assignment=false
1018- next_word+=' :start: '
1018+ next_word+=' s '
10191019 continue
10201020 elif (( in_redirection )) ; then
10211021 style=unknown-token
@@ -1035,7 +1035,7 @@ _zsh_highlight_main_highlighter_highlight_list()
10351035 else
10361036 if [[ $zsyh_user_options [multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
10371037 then
1038- next_word+=' :start::start_of_pipeline: '
1038+ next_word+=' sp '
10391039 fi
10401040 style=reserved-word
10411041 fi
@@ -1051,7 +1051,7 @@ _zsh_highlight_main_highlighter_highlight_list()
10511051 else
10521052 _zsh_highlight_main__stack_pop ' Y' reserved-word
10531053 if [[ $style == reserved-word ]]; then
1054- next_word+=' :always: '
1054+ next_word+=' w '
10551055 fi
10561056 fi
10571057 elif [[ $arg [0,1] = $histchars [0,1] ]] && (( $# arg[0 , 2 ] == 2 )) ; then
@@ -1885,4 +1885,4 @@ typeset -gA _zsh_highlight_main__fallback_of=(
18851885 command-substitution{-delimiter,}
18861886 process-substitution{-delimiter,}
18871887 back-quoted-argument{-delimiter,}
1888- )
1888+ )
0 commit comments