<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd"
[
        <!ENTITY tab      "&#009;">
        <!ENTITY funcname "[^&_fragpathseps;=]*+">
        <!ENTITY varname  "[A-Za-z_][A-Za-z0-9_]*">
        <!ENTITY eos      "(?=$|[ &tab;])">                 <!-- eol or space following -->
        <!ENTITY eoexpr   "(?=$|[ &tab;&lt;>|&amp;;)])">

        <!ENTITY substseps  "${}'&quot;`\\">
        <!ENTITY symbolseps "&lt;>|&amp;;()">
        <!ENTITY wordseps   " &tab;&symbolseps;">
        <!ENTITY wordseps_or_extglog " &tab;>|&amp;;)`"> <!-- wordseps without < and ( -->

        <!ENTITY bq_string  "`[^`]*+`">
        <!ENTITY sq_string  "'[^']*+'">
        <!ENTITY dq_string  "&quot;(?:[^&quot;\\`]*+|&bq_string;|\\.)*+&quot;">
        <!ENTITY strings    "(?:&sq_string;|&dq_string;|&bq_string;)">

        <!ENTITY simpleglob "*?#^~">
        <!ENTITY globrange  "&lt;[0-9]*-[0-9]*>">
        <!ENTITY globany    "\[(?:[^&wordseps;&quot;'`\\\[\]]+|\\.|&strings;|\[:\w+:\]|\[)*\]">

        <!ENTITY _fragpathseps  "&simpleglob;[&wordseps;&substseps;">
        <!ENTITY _fragpathnosep "(?:&_brace_noexpansion;)?+">
        <!ENTITY path        "(?:[^&_fragpathseps;]*+&_fragpathnosep;)*+">
        <!ENTITY fragpath    "(?:[^&_fragpathseps;/]*+&_fragpathnosep;)*+">
        <!ENTITY fragpathesc "\\.(?:[^&_fragpathseps;/]*+(?:\\.|&_brace_noexpansion;)?+)*+">
        <!ENTITY opt         "(?:[^&_fragpathseps;=/]*+&_fragpathnosep;)*+">
        <!ENTITY assumepath  "/&path;|(?=[&simpleglob;([]|&globrange;)">
        <!ENTITY pathpart    "(?:~(?:/&path;|(?=[&wordseps;]|$))|&fragpath;(?:&assumepath;|(?=&fragpathesc;&assumepath;))|\.\.?(?=[&wordseps;]|$))">

        <!-- Path only with / -->
        <!ENTITY path_with_sep_text  "[^[&wordseps;'&quot;`\\/]">
        <!ENTITY path_with_sep_text2 "[^[()&lt;>'&quot;`\\/]">
        <!ENTITY path_with_sep_expr  "\\.|&strings;|&globany;|&globrange;">
        <!ENTITY path_with_sep_spe   "(~|\.\.?)($|[/ &tab;&lt;>|&amp;;)])">
        <!ENTITY path_with_sep_sub   "\((&path_with_sep_text2;++|&path_with_sep_expr;)*+(\)|(?=/))">
        <!ENTITY path_with_sep "/|&path_with_sep_spe;|(&path_with_sep_text;++|&path_with_sep_expr;|&path_with_sep_sub;)*+/">

        <!ENTITY _braceexpansion_spe     " &tab;&lt;>|&amp;;{}\\`'&quot;$">
        <!ENTITY _brace_noexpansion      "\{[^&_braceexpansion_spe;,]*+\}">
        <!ENTITY _braceexpansion_var     "\$(?:\{[^\[\]&_braceexpansion_spe;]*+(?:\[[*@a-zA-Z0-9]\])\})?">
        <!ENTITY _braceexpansion_elems   "\\.|&strings;|&_braceexpansion_var;|&_brace_noexpansion;">
        <!ENTITY _braceexpansion_consume "&_braceexpansion_elems;|{(?:[^&_braceexpansion_spe;,]++|&_braceexpansion_elems;)*?}|(?R)?+">
        <!ENTITY _braceexpansion "(?:[^&_braceexpansion_spe;,]++|&_braceexpansion_consume;)*?,(?:[^&_braceexpansion_spe;]++|&_braceexpansion_consume;)*?}">
        <!ENTITY braceexpansion "{&_braceexpansion;">

        <!ENTITY _bracerangevar "\$([#+^=~]*([_a-zA-Z0-9]+|[*@#])(\[((\$[#+^=~]*)?([-+_a-zA-Z0-9]+|[*@])|$#)\])?|#|'(\\.|[^'\\])')">
        <!ENTITY _bracerangeoperand "-?([0-9]+|[a-zA-Z!#$&#37;*+,-./:=?@^_~]|&_bracerangevar;|\\.|'[^'\\]'|&quot;(\\.|[^&quot;\\`])&quot;|`[^`]*`)">
        <!ENTITY bracerangeexpansion "{(?=&_bracerangeoperand;\.\.&_bracerangeoperand;(\.\.-?([0-9]+|&_bracerangevar;))?})">

        <!ENTITY nobraceexpansion "(?:{([^&_braceexpansion_spe;/{},]++|(?R))+?})+">
        <!ENTITY nogroupend "(?:}+(?:[^&_fragpathseps;]|(?=[}$'&quot;`\\])))">

        <!-- glob with |, ( or spaces is a pattern -->
        <!ENTITY _ispattern_ugN "[ug][0123456789]+">
        <!ENTITY _ispattern_ugeP "[ugeP](?:&_ispattern_ugeP_0;|&_ispattern_ugeP_1;|&_ispattern_ugeP_2;|&_ispattern_ugeP_3;|&_ispattern_ugeP_4;|(?=\|))">
        <!ENTITY _ispattern_ugeP_0    ":(?:[^:'`&quot;\\|()]*+(?:&_ispattern_q;)?)*(?::|(?=[|()]))">
        <!ENTITY _ispattern_ugeP_1   "\[(?:[^]'`&quot;\\|()]*+(?:&_ispattern_q;)?)*(?:\](?=[|()]))">
        <!ENTITY _ispattern_ugeP_2    "{(?:[^}'`&quot;\\|()]*+(?:&_ispattern_q;)?)*(?:}(?=[|()]))">
        <!ENTITY _ispattern_ugeP_3 "&lt;(?:[^>'`&quot;\\|()]*+(?:&_ispattern_q;)?)*(?:>|(?=[|()]))">
        <!ENTITY _ispattern_ugeP_4  "([^&wordseps;{}'&quot;`\\])(?:(?:(?!\1)[^'`&quot;\\\1|()])*+(?:&_ispattern_q;)?)*(?:\1|(?=[|()]))">
        <!ENTITY _ispattern_q "\\.|&strings;">
        <!ENTITY _ispattern_check "(?:\)(?:[^ &tab;}&lt;>|&amp;;)]|&nogroupend;)|[ &tab;|(]|$)">
        <!ENTITY ispattern "(?:[^ &tab;\\'&quot;|()`ugeP]*+(?:&_ispattern_ugN;|&_ispattern_ugeP;|&_ispattern_q;)?)*&_ispattern_check;">

        <!ENTITY heredocq "(?|&quot;([^&quot;]+)&quot;|'([^']+)'|\\(.[^&wordseps;&substseps;]*))">

        <!ENTITY arithmetic_as_subshell "\(((?:[^`'&quot;()$]++|\$\{[^`'&quot;(){}$]+\}|\$(?=[^{`'&quot;()])|&bq_string;|\((?1)(?:[)]|(?=['&quot;])))++)(?:[)](?=$|[^)])|[&quot;'])">

        <!ENTITY unary_operators  "-[abcdefghknoprstuvwxzLOGNS]&eos;">
        <!ENTITY binary_operators "(?:-(?:e[fq]|[nolg]t|[nlg]e)|==?|!=)&eos;">

        <!ENTITY dblbracket_close "\]\](?=($|[ &tab;;|&amp;)]))">

        <!ENTITY int "(?:[0-9]++[_0-9]*+)">
        <!ENTITY exp "(?:[eE][-+]?&int;)">
]>
<language name="Zsh" version="28" kateversion="5.79" section="Scripts" extensions="*.sh;*.zsh;.zshrc;.zprofile;.zlogin;.zlogout;.profile" mimetype="application/x-shellscript" casesensitive="1" author="Jonathan Poelen (jonathan.poelen@gmail.com)" license="MIT">

  <highlighting>
    <list name="keywords">
      <item>continue</item>
      <item>break</item>
      <item>case</item>
      <item>do</item>
      <item>done</item>
      <item>elif</item>
      <item>else</item>
      <item>end</item>
      <item>esac</item>
      <item>fi</item>
      <item>for</item>
      <item>foreach</item>
      <item>function</item>
      <item>if</item>
      <item>in</item>
      <item>repeat</item>
      <item>return</item>
      <item>select</item>
      <item>then</item>
      <item>until</item>
      <item>while</item>
    </list>

<list name="builtins"><!-- see man zshbuiltins -->
	<item>-</item>
	<item>.</item>
	<item>:</item>
	<item>alias</item>
	<item>autoload</item>
	<item>bg</item>
	<item>bindkey</item>
	<item>builtin</item>
	<item>bye</item>
	<item>cap</item>
	<item>cd</item>
	<item>chdir</item>
	<item>clone</item>
	<item>command</item>
	<item>comparguments</item>
	<item>compcall</item>
	<item>compctl</item>
	<item>compdescribe</item>
	<item>compfiles</item>
	<item>compgroups</item>
	<item>compquote</item>
	<item>comptags</item>
	<item>comptry</item>
	<item>compvalues</item>
	<item>coproc</item>
	<item>dirs</item>
	<item>disable</item>
	<item>disown</item>
	<item>echo</item>
	<item>echotc</item>
	<item>echoti</item>
	<item>emulate</item>
	<item>enable</item>
	<item>eval</item>
	<item>exec</item>
	<item>exit</item>
	<item>false</item>
	<item>fc</item>
	<item>fg</item>
	<item>functions</item>
	<item>getcap</item>
	<item>hash</item>
	<item>history</item>
	<item>jobs</item>
	<item>kill</item>
	<item>limit</item>
	<item>log</item>
	<item>logout</item>
	<item>nocorrect</item>
	<item>noglob</item>
	<item>popd</item>
	<item>print</item>
	<item>printf</item>
	<item>pushd</item>
	<item>pushln</item>
	<item>pwd</item>
	<item>r</item>
	<item>rehash</item>
	<item>sched</item>
	<item>set</item>
	<item>setcap</item>
	<item>setopt</item>
	<item>shift</item>
	<item>source</item>
	<item>stat</item>
	<item>suspend</item>
	<item>test</item>
	<item>times</item>
	<item>trap</item>
	<item>true</item>
	<item>ttyctl</item>
	<item>type</item>
	<item>ulimit</item>
	<item>umask</item>
	<item>unalias</item>
	<item>unfunction</item>
	<item>unhash</item>
	<item>unlimit</item>
	<item>unset</item>
	<item>unsetopt</item>
	<item>vared</item>
	<item>wait</item>
	<item>whence</item>
	<item>where</item>
	<item>which</item>
	<item>zcompile</item>
	<item>zformat</item>
	<item>zftp</item>
	<item>zle</item>
	<item>zmodload</item>
	<item>zparseopts</item>
	<item>zprof</item>
	<item>zpty</item>
	<item>zregexparse</item>
	<item>zsocket</item>
	<item>zstyle</item>
	<item>ztcp</item>
    </list>

    <list name="builtins_var">
	<item>declare</item>
	<item>export</item>
	<item>float</item>
	<item>getln</item>
	<item>getopts</item>
	<item>integer</item>
	<item>let</item>
	<item>local</item>
	<item>read</item>
	<item>readonly</item>
	<item>typeset</item>
	<item>unset</item>
    </list>

    <list name="unixcommands">
      <include>unixcommands##Bash</include>
    </list>

    <contexts>
      <context attribute="Normal Text" lineEndContext="#stay" name="Start" fallthroughContext="Command">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
        <!-- start expression in double parentheses -->
        <Detect2Chars context="ExprDblParenOrSubShell" char="(" char1="(" lookAhead="1"/>
        <!-- start a subshell -->
        <DetectChar attribute="Keyword" context="SubShell" char="(" beginRegion="subshell"/>
        <!-- start expression in single/double brackets -->
        <DetectChar context="MaybeBracketExpression" char="[" lookAhead="1"/>
        <!-- start a group command or BraceExpansion with { -->
        <DetectChar attribute="Keyword" context="Group" char="{"/>

        <!-- handle ` -->
        <DetectChar attribute="Backquote" context="CommandBackq" char="`"/>

        <!-- &> redirections -->
        <Detect2Chars attribute="Redirection" context="Prefix&amp;>" char="&amp;" char1=">"/>
        <Detect2Chars attribute="Control" context="#stay" char="&amp;" char1="!"/>

        <!-- handle branche conditions -->
        <Detect2Chars attribute="Control" context="#stay" char="&amp;" char1="&amp;"/>
        <Detect2Chars attribute="Control" context="#stay" char="|" char1="|"/>

        <!-- handle &, |, ; -->
        <AnyChar attribute="Control" context="#stay" String="&amp;|;"/>

        <!-- handle variable assignments -->
        <RegExpr attribute="Variable" context="VarAssign" String="&varname;(?=\+?=|\[(?:$|[^]]))|[0-9]+(?=\+?=)"/>
        <!-- handle keywords -->
        <keyword context="DispatchKeyword" String="keywords" lookAhead="1"/>
        <!-- handle commands that have variable names as argument -->
        <keyword attribute="Builtin" context="VarName" String="builtins_var" lookAhead="1"/>
        <WordDetect attribute="Builtin" context="#stay" String="noglob"/>
        <!-- mark function definitions without function keyword -->
        <RegExpr attribute="Function" context="#stay" String="&funcname;[ &tab;]*\(\)"/>
        <keyword attribute="Builtin" context="CommandArgs" String="builtins"/>
        <keyword attribute="Command" context="CommandArgs" String="unixcommands"/>

        <!-- handle redirection -->
        <AnyChar context="CommandMaybeRedirection" String="&lt;&gt;0123456789" lookAhead="1"/>

        <DetectChar attribute="Error" context="#stay" char=")"/>
        <DetectChar context="MaybeGroupEnd" char="}" lookAhead="1"/>

        <LineContinue attribute="Escape" context="#stay"/>

        <Detect2Chars attribute="Expression" context="#stay" char="!" char1=" "/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="MaybeGroupEnd">
        <RegExpr context="#pop!Command" String="&nogroupend;" lookAhead="1"/>
        <DetectChar attribute="Error" context="#pop" char="}"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="MaybeBracketExpression" fallthroughContext="#pop!Command">
        <!-- start expression in double brackets -->
        <RegExpr attribute="Keyword" context="#pop!ExprDblBracket" String="\[\[(?=$|[ &tab;(])" beginRegion="expression"/>
        <!-- start expression in single brackets -->
        <RegExpr attribute="Builtin" context="#pop!ExprBracket" String="\[&eos;" beginRegion="expression"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="CommandMaybeRedirection" fallthroughContext="#pop!Command">
        <IncludeRules context="FindRedirection"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="Return" fallthroughContext="#pop">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <Int attribute="Number" context="#stay"/>
      </context>
      <!-- Comment consumes shell comments till EOL -->
      <context attribute="Comment" lineEndContext="#pop" name="Comment">
        <DetectSpaces attribute="Comment"/>
        <IncludeRules context="##Comments"/>
        <DetectIdentifier attribute="Comment" context="#stay"/>
      </context>

      <!-- Group is called after a { is encountered -->
      <context attribute="Normal Text" lineEndContext="#stay" name="Group" fallthroughContext="Command">
        <DetectChar attribute="Keyword" context="#pop!GroupEnd" char="}"/>
        <IncludeRules context="Start"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="GroupEnd" fallthroughContext="#pop!CommandArgs">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <WordDetect attribute="Control Flow" context="#pop" String="always"/>
      </context>

      <context attribute="OtherCommand" lineEndContext="#pop" name="Command">
        <DetectSpaces attribute="Normal Text" context="#pop!CommandArgs"/>
        <DetectIdentifier attribute="OtherCommand" context="#stay"/>
        <DetectChar context="CommandVariables" char="$" lookAhead="1"/>
        <IncludeRules context="FindStrings"/>
        <Detect2Chars attribute="Control" context="#pop" char="&amp;" char1="&amp;"/>
        <Detect2Chars attribute="Control" context="#pop" char="|" char1="|"/>
        <DetectChar attribute="Control" context="#pop" char="|"/>
        <AnyChar context="#pop" String=";)`" lookAhead="1"/>
        <AnyChar context="#pop!CommandArgs" String="&amp;&lt;>" lookAhead="1"/>
        <!-- start expression in double parentheses -->
        <Detect2Chars attribute="Error" context="#pop!ExprDblParen" char="(" char1="(" beginRegion="expression"/>
        <!-- start a subshell -->
        <DetectChar attribute="Error" context="#pop!SubShell" char="(" beginRegion="subshell"/>
        <DetectChar context="CommandAssumeEscape" char="\" lookAhead="1"/>
        <DetectChar context="CommandMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar context="CommandMaybeGroupEnd" char="}" lookAhead="1"/>
      </context>
      <context attribute="Command" lineEndContext="#pop" name="CommandVariables">
        <IncludeRules context="DispatchVariables"/>
        <DetectChar attribute="OtherCommand" context="#pop" char="$"/>
      </context>
      <context attribute="OtherCommand" lineEndContext="#pop" name="CommandAssumeEscape">
        <LineContinue attribute="Escape" context="#pop"/>
        <RegExpr attribute="OtherCommand" context="#pop" String="\\."/>
      </context>
      <context attribute="OtherCommand" lineEndContext="#pop" name="CommandMaybeBraceExpansion">
        <IncludeRules context="DispatchBraceExpansion"/>
        <DetectChar attribute="OtherCommand" context="#pop" char="{"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="CommandMaybeGroupEnd">
        <RegExpr attribute="OtherCommand" context="#pop" String="&nogroupend;+"/>
        <DetectChar context="#pop#pop" char="}" lookAhead="1"/>
      </context>

      <context attribute="Variable" lineEndContext="#pop" name="DispatchVariables">
        <IncludeRules context="DispatchSubstVariables"/>
        <IncludeRules context="DispatchStringVariables"/>
        <IncludeRules context="DispatchVarNameVariables"/>
      </context>
      <context attribute="Variable" lineEndContext="#pop" name="DispatchSubstVariables">
        <Detect2Chars attribute="Parameter Expansion" context="#pop!VarBraceStart" char="$" char1="{"/>
        <StringDetect context="#pop!ExprDblParenSubstOrSubstCommand" String="$((" lookAhead="1"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop!SubstCommand" char="$" char1="(" beginRegion="subshell"/>
      </context>
      <context attribute="Variable" lineEndContext="#pop" name="DispatchStringVariables">
        <Detect2Chars attribute="String SingleQ" context="#pop!StringEsc" char="$" char1="'"/>
        <Detect2Chars attribute="String Transl." context="#pop!StringDQ" char="$" char1="&quot;"/>
      </context>
      <context attribute="Variable" lineEndContext="#pop" name="DispatchVarNameVariables">
        <Detect2Chars context="#pop!VarNameSpe" char="$" char1="#" lookAhead="1"/>
        <RegExpr attribute="Variable" context="#pop!AfterVarName" String="\$(?:&varname;|[0-9]+|[-*@?$!])"/>
        <Detect2Chars context="#pop!VarNameSpe" char="$" char1="~" lookAhead="1"/>
        <Detect2Chars context="#pop!VarNameSpe" char="$" char1="=" lookAhead="1"/>
        <Detect2Chars context="#pop!VarNameSpe" char="$" char1="^" lookAhead="1"/>
        <Detect2Chars context="#pop!VarNameSpe" char="$" char1="+" lookAhead="1"/>
      </context>
      <context attribute="Variable" lineEndContext="#pop" name="VarNameSpe">
        <DetectChar attribute="Variable" context="#pop!VarNameSpeParam" char="$"/>
      </context>
      <context attribute="Variable" lineEndContext="#pop" name="VarNameSpeParam">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarNameSubstLen" char="#"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarNameParam+" char="+"/>
        <AnyChar attribute="Parameter Expansion Operator" context="#pop!VarNameParam" String="~=^"/>
      </context>
      <context attribute="Variable" lineEndContext="#pop" name="VarNameSubstLen" fallthroughContext="#pop!AfterVarName">
        <DetectIdentifier attribute="Variable" context="#pop!AfterVarName"/>
        <AnyChar attribute="Variable" context="#pop!AfterVarName" String="-*@?$!"/>
        <Int attribute="Variable" context="#pop!AfterVarName" additionalDeliminator="#~=^+{}[]:-/$"/>
      </context>
      <context attribute="Variable" lineEndContext="#pop" name="VarNameParam" fallthroughContext="#pop!AfterVarName">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarNameSubstLen" char="#"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarNameParam+" char="+"/>
        <AnyChar attribute="Parameter Expansion Operator" context="#stay" String="^=~"/>
        <IncludeRules context="VarNameSubstLen"/>
      </context>
      <context attribute="Variable" lineEndContext="#pop" name="VarNameParam+" fallthroughContext="#pop">
        <IncludeRules context="VarNameSubstLen"/>
      </context>

      <!-- called as soon as $xxx is encoutered -->
      <context attribute="Normal Text" lineEndContext="#pop" name="AfterVarName" fallthroughContext="#pop">
        <DetectChar context="VarNameDispatchModifiers" char=":" lookAhead="1"/>
        <DetectChar attribute="Parameter Expansion Operator" context="Subscript" char="["/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop#pop" name="VarNameDispatchModifiers" fallthroughContext="#pop#pop">
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="a"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="A"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="c"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="e"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop!VarNameModifier_h" char=":" char1="h"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="l"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="p"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="P"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="q"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="Q"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="r"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop!VarNameModifier_s" char=":" char1="s"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop!VarNameModifier_h" char=":" char1="t"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="u"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="x"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop" char=":" char1="&amp;"/>
        <StringDetect attribute="Parameter Expansion" context="#pop!VarNameModifier_s" String=":gs"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop#pop" name="VarNameModifier_h" fallthroughContext="#pop">
        <AnyChar attribute="Number" context="#stay" String="0123456789"/>
      </context>
      <context attribute="Parameter Expansion Operator" lineEndContext="#pop#pop" name="VarNameModifier_s" fallthroughContext="#pop#pop">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarNameModifier_s_Str" char="/"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#pop#pop" name="VarNameModifier_s_Str">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarNameModifier_s_Rep" char="/"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <DetectChar attribute="String DoubleQ" context="#pop" char="&quot;"/>
        <DetectChar attribute="String SingleQ" context="#pop" char="'"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#pop#pop" name="VarNameModifier_s_Rep">
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="/"/>
        <AnyChar context="#pop#pop" String=" &tab;&lt;>|&amp;;()" lookAhead="1"/>
        <DetectIdentifier attribute="String SingleQ"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="CommandBackq" fallthroughContext="Command">
        <DetectChar attribute="Backquote" context="#pop!CommandArgs" char="`"/>
        <DetectChar attribute="Comment" context="CommentBackq" char="#"/>
        <IncludeRules context="Start"/>
      </context>
      <!-- CommentBackq consumes shell comments till EOL or a backquote -->
      <context attribute="Comment" lineEndContext="#pop" name="CommentBackq">
        <DetectChar context="#pop" char="`" lookAhead="1"/>
        <IncludeRules context="Comment"/>
      </context>

      <!-- CommandArgs matches the items after a command -->
      <context attribute="Normal Text" lineEndContext="#pop" name="CommandArgs" fallthroughContext="CommandArg">
        <DetectSpaces attribute="Normal Text" context="#stay"/>

        <!-- &> redirections -->
        <Detect2Chars attribute="Redirection" context="Prefix&amp;>" char="&amp;" char1=">"/>

        <!-- handle &, |, ;, ` -->
        <AnyChar context="#pop" String="&amp;|;`" lookAhead="1"/>

        <!-- handle process subst -->
        <Detect2Chars attribute="Redirection" context="ProcessSubst" char="=" char1="("/>
        <!-- handle redirection -->
        <AnyChar context="CommandArgMaybeRedirection" String="&gt;&lt;0123456789" lookAhead="1"/>

        <DetectChar context="#pop" char=")" lookAhead="1"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop#pop" name="CommandArg" fallthroughContext="#pop!NormalOption">
        <!-- In command arguments, do not allow comments after escaped characters.
             This avoids highlighting comments within paths or other text. Ex: pathtext\ #no\ comment -->
        <DetectChar context="#pop#pop" char="#" lookAhead="1"/>
        <Detect2Chars attribute="Option" context="#pop!LongOption" char="-" char1="-"/>
        <DetectChar attribute="Option" context="#pop!ShortOption" char="-"/>
        <DetectChar attribute="Keyword" context="#pop!NormalOption" char="="/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="CommandArgMaybeRedirection" fallthroughContext="#pop!NormalOption">
        <IncludeRules context="FindRedirection"/>
      </context>

      <context attribute="Option" lineEndContext="#pop" name="ShortOption" fallthroughContext="#pop">
        <DetectChar attribute="Path" context="PathThenPop" char="/"/>
        <IncludeRules context="LongOption"/>
      </context>
      <context attribute="Option" lineEndContext="#pop" name="LongOption" fallthroughContext="#pop">
        <AnyChar context="#pop" String="&wordseps_or_extglog;" lookAhead="1"/>
        <DetectChar attribute="Operator" context="#pop!NormalOption" char="="/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindSingleGlob"/>
        <IncludeRules context="FindGlobAny"/>
        <AnyChar context="#pop!NormalOption" String="({}&lt;" lookAhead="1"/>
        <RegExpr attribute="Option" context="#stay" String="&opt;"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="NormalOption" fallthroughContext="#pop">
        <AnyChar context="#pop" String="&wordseps_or_extglog;" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <DetectChar attribute="Glob" context="PathThenPop" char="[" lookAhead="1"/>
        <DetectChar context="ExprGlobParenThenPath" char="(" lookAhead="1"/>
        <IncludeRules context="FindPathThenPop"/>
        <DetectChar context="NormalOptionMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar context="NormalOptionMaybeGroupEnd" char="}" lookAhead="1"/>
        <IncludeRules context="FindNormalTextOption"/>
        <DetectChar context="MaybeGlobRangeOrPop" char="&lt;" lookAhead="1"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop#pop" name="NormalOptionRecBrace">
        <AnyChar context="#pop#pop" String="&wordseps_or_extglog;" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindSingleGlob"/>
        <IncludeRules context="FindGlobAny"/>
        <DetectChar context="ExprGlobParen" char="(" lookAhead="1"/>
        <DetectChar context="NormalOptionMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar attribute="Normal Text" context="#pop" char="}"/>
        <DetectChar context="MaybeGlobRangeOrPop" char="&lt;" lookAhead="1"/>
        <DetectIdentifier/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="NormalOptionMaybeGroupEnd">
        <IncludeRules context="FindNoGroupEndThenPop"/>
        <DetectChar context="#pop#pop#pop" char="}" lookAhead="1"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="FindNoGroupEndThenPop">
        <RegExpr context="#pop" String="&nogroupend;"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="FindNormalTextOption">
        <RegExpr attribute="Normal Text" context="#stay" String="([^[&wordseps;&substseps;]+|&nogroupend;)+"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="NormalOptionMaybeBraceExpansion">
        <IncludeRules context="DispatchBraceExpansion"/>
        <DetectChar attribute="Normal Text" context="#pop!NormalOptionRecBrace" char="{"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="AssumeEscape">
        <LineContinue attribute="Escape" context="#pop"/>
        <RegExpr attribute="Escape" context="#pop" String="\\."/>
      </context>

<!-- ====== The following rulessets are meant to be included ======== -->

      <!-- FindRedirection consumes shell redirection -->
      <context attribute="Normal Text" lineEndContext="#pop" name="FindRedirection">
        <RegExpr attribute="File Descriptor" context="#pop!AssumeRedirection" String="[0-9]++(?=[&lt;>])"/>
        <IncludeRules context="AssumeRedirection"/>
      </context>

      <!-- DispatchBraceExpansion consumes brace expansions -->
      <context attribute="Normal Text" lineEndContext="#pop" name="DispatchBraceExpansion">
        <RegExpr context="#pop!BraceExpansion" String="&braceexpansion;" lookAhead="1"/>
        <IncludeRules context="IncBraceExpansion"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="DispatchPathBraceExpansion">
        <RegExpr context="#pop!PathBraceExpansion" String="&braceexpansion;" lookAhead="1"/>
        <IncludeRules context="IncBraceExpansion"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="IncBraceExpansion">
        <RegExpr attribute="Escape" context="#pop!SequenceExpression" String="&bracerangeexpansion;"/>
        <RegExpr context="#pop" String="&nobraceexpansion;"/>
      </context>

      <!-- FindPathThenPop consumes path -->
      <context attribute="Normal Text" lineEndContext="#pop" name="FindPathThenPop">
        <AnyChar attribute="Glob" context="PathThenPop" String="?*#^"/>
        <RegExpr attribute="Path" context="PathThenPop" String="&pathpart;"/>
        <DetectChar attribute="Glob" context="PathThenPop" char="~"/>
      </context>
      <context attribute="Path" lineEndContext="#pop#pop" name="IncPath">
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindSingleGlob"/>
        <IncludeRules context="FindGlobAny"/>
        <DetectChar context="ExprGlobParen" char="(" lookAhead="1"/>
        <RegExpr attribute="Path" context="#stay" String="&path;"/>
        <DetectChar context="MaybeGlobRangeOrPop" char="&lt;" lookAhead="1"/>
        <DetectChar context="PathMaybeBraceExpansion" char="{" lookAhead="1"/>
      </context>
      <context attribute="Path" lineEndContext="#pop#pop" name="PathThenPop">
        <AnyChar context="#pop#pop" String="&wordseps_or_extglog;" lookAhead="1"/>
        <IncludeRules context="IncPath"/>
        <DetectChar context="PathMaybeGroupEnd" char="}" lookAhead="1"/>
        <DetectIdentifier attribute="Path"/>
      </context>
      <context attribute="Path" lineEndContext="#pop" name="PathRecBrace">
        <AnyChar context="#pop" String="&wordseps_or_extglog;" lookAhead="1"/>
        <IncludeRules context="IncPath"/>
        <DetectChar attribute="Path" context="#pop" char="}"/>
        <DetectIdentifier attribute="Path"/>
      </context>
      <context attribute="Glob" lineEndContext="#stay" name="MaybeGlobRangeOrPop" fallthroughContext="#pop#pop">
        <IncludeRules context="FindGlobRangeThenPop"/>
      </context>
      <context attribute="Path" lineEndContext="#pop" name="PathMaybeBraceExpansion">
        <IncludeRules context="DispatchPathBraceExpansion"/>
        <DetectChar attribute="Path" context="#pop!PathRecBrace" char="{"/>
      </context>
      <context attribute="Path" lineEndContext="#pop" name="PathMaybeGroupEnd">
        <IncludeRules context="FindNoGroupEndThenPop"/>
        <DetectChar context="#pop#pop#pop" char="}" lookAhead="1"/>
      </context>
      <context attribute="Glob" lineEndContext="#stay" name="FindGlobRangeThenPop">
        <RegExpr attribute="Glob" context="#pop!InGlobRange" String="&lt;(?=[0-9]*-[0-9]*>)"/>
      </context>
      <context attribute="Number" lineEndContext="#stay" name="InGlobRange">
        <AnyChar attribute="Number" context="#stay" String="0123456789"/>
        <DetectChar attribute="Glob" context="#stay" char="-"/>
        <DetectChar attribute="Glob" context="#pop" char=">"/>
      </context>

      <!-- FindPathThenPopInAlternateValue consumes path in ${xx:here}-->
      <context attribute="Normal Text" lineEndContext="#pop" name="FindPathThenPopInAlternateValue">
        <AnyChar attribute="Glob" context="PathThenPopInAlternateValue" String="&simpleglob;|"/>
        <Detect2Chars context="PathThenPopInAlternateValue" char="(" char1="#" lookAhead="1"/>
        <AnyChar context="PathThenPopInAlternateValue" String="[(" lookAhead="1"/>
        <RegExpr attribute="Path" context="PathThenPopInAlternateValue" String="&pathpart;"/>
      </context>
      <context attribute="Path" lineEndContext="#pop" name="PathThenPopInAlternateValue">
        <AnyChar context="#pop" String="&wordseps_or_extglog;}" lookAhead="1"/>
        <IncludeRules context="IncPath"/>
        <DetectIdentifier/>
      </context>

      <context attribute="Glob" lineEndContext="#stay" name="FindGlobAny">
        <DetectChar attribute="Glob" context="GlobAnyFlag" char="["/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#pop" name="GlobAnyFlag" fallthroughContext="#pop!GlobAny">
        <DetectChar attribute="Glob Flag" context="#pop!GlobAny" char="^"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#pop" name="GlobAny">
        <DetectIdentifier attribute="String SingleQ"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <DetectChar attribute="Glob Flag" context="#stay" char="-"/>
        <IncludeRules context="FindStrings"/>
        <DetectChar attribute="Glob" context="#pop" char="]"/>
        <Detect2Chars attribute="Glob" context="GlobClass" char="[" char1=":"/>
      </context>
      <context attribute="Glob" lineEndContext="#pop#pop" name="GlobClass">
        <DetectIdentifier attribute="Pattern"/>
        <Detect2Chars attribute="Glob" context="#pop" char=":" char1="]"/>
        <DetectChar attribute="Error" context="#pop" char="]"/>
      </context>

      <context attribute="Pattern" lineEndContext="#stay" name="FindSingleGlob">
        <AnyChar attribute="Glob" context="#stay" String="&simpleglob;"/>
      </context>

      <context attribute="Pattern" lineEndContext="#stay" name="FindGlobPattern">
        <AnyChar attribute="Glob" context="#stay" String="&simpleglob;|"/>
        <IncludeRules context="FindGlobAny"/>
        <IncludeRules context="FindGroupPattern"/>
      </context>

      <context attribute="Pattern" lineEndContext="#stay" name="FindPattern">
        <IncludeRules context="FindGlobPattern"/>
        <DetectChar context="GlobRangeOrError" char="&lt;" lookAhead="1"/>
      </context>
      <context attribute="Glob" lineEndContext="#stay" name="GlobRangeOrError">
        <IncludeRules context="FindGlobRangeThenPop"/>
        <DetectChar attribute="Error" context="#pop" char="&lt;"/>
      </context>

      <context attribute="Pattern" lineEndContext="#stay" name="FindSubPattern">
        <IncludeRules context="FindGlobPattern"/>
        <DetectChar context="GlobRangeOrPattern" char="&lt;" lookAhead="1"/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="GlobRangeOrPattern">
        <IncludeRules context="FindGlobRangeThenPop"/>
        <DetectChar attribute="Pattern" context="#pop" char="&lt;"/>
      </context>

      <context attribute="Pattern" lineEndContext="#stay" name="FindStringDQPattern">
        <IncludeRules context="FindGlobPattern"/>
        <DetectChar context="GlobRangeOrStringDQ" char="&lt;" lookAhead="1"/>
      </context>
      <context attribute="String DoubleQ" lineEndContext="#stay" name="GlobRangeOrStringDQ">
        <IncludeRules context="FindGlobRangeThenPop"/>
        <DetectChar attribute="String DoubleQ" context="#pop" char="&lt;"/>
      </context>

      <context attribute="Glob Flag" lineEndContext="#stay" name="FindGroupPattern">
        <Detect2Chars attribute="Glob Flag" context="GlobPatFlag" char="(" char1="#"/>
        <DetectChar attribute="Glob" context="ExtGlobPattern" char="("/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="ExtGlobPattern">
        <DetectChar attribute="Glob" context="#pop" char=")"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindSubPattern"/>
        <DetectIdentifier attribute="Pattern"/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="ExtGlobPatternThenPath">
        <DetectChar attribute="Glob" context="#pop!PathThenPop" char=")"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindSubPattern"/>
        <DetectIdentifier attribute="Pattern"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="VarAssign" fallthroughContext="#pop">
        <DetectChar attribute="Parameter Expansion Operator" context="Subscript" char="["/>
        <DetectChar attribute="Operator" context="#pop!Assign" char="="/>
        <Detect2Chars attribute="Operator" context="#pop!Assign" char="+" char1="="/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="DispatchKeyword">
        <!-- match do and if blocks -->
        <Detect2Chars attribute="Control Flow" context="#pop!NotCond" char="i" char1="f" beginRegion="if"/>
        <Detect2Chars attribute="Control Flow" context="#pop" char="f" char1="i" endRegion="if"/>
        <StringDetect attribute="Control Flow" context="#pop" String="done" endRegion="do"/>
        <Detect2Chars attribute="Control Flow" context="#pop" char="d" char1="o" beginRegion="do"/>
        <!-- handle while/until as a special case -->
        <StringDetect attribute="Control Flow" context="#pop!NotCond" String="while"/>
        <StringDetect attribute="Control Flow" context="#pop!NotCond" String="until"/>
        <!-- handle for as a special case -->
        <StringDetect attribute="Control Flow" context="#pop!Foreach" String="foreach"/>
        <StringDetect attribute="Control Flow" context="#pop!For" String="for"/>
        <!-- handle select as a special case -->
        <StringDetect attribute="Control Flow" context="#pop!Select" String="select"/>
        <StringDetect attribute="Control Flow" context="#pop!Repeat" String="repeat"/>
        <!-- handle case as a special case -->
        <StringDetect attribute="Control Flow" context="#pop!Case" String="case" beginRegion="case"/>
        <!-- handle functions with function keyword before keywords -->
        <StringDetect attribute="Keyword" context="#pop!FunctionDef" String="function"/>
        <StringDetect attribute="Control Flow" context="#pop!Return" String="return"/>
        <!-- not a keyword in this context -->
        <Detect2Chars attribute="Error" context="#pop" char="i" char1="n"/>
        <StringDetect attribute="Error" context="#pop" String="esac"/>
        <!-- handle keywords -->
        <DetectIdentifier attribute="Control Flow" context="#pop"/>
      </context>

      <!-- if ! ... and while ! ... -->
      <context attribute="Normal Text" lineEndContext="#pop" name="NotCond" fallthroughContext="#pop">
        <DetectSpaces attribute="Normal Text" context="#pop!NotCond2"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="NotCond2" fallthroughContext="#pop">
        <Detect2Chars attribute="Expression" context="#pop" char="!" char1="&tab;"/>
        <Detect2Chars attribute="Expression" context="#pop" char="!" char1=" "/>
        <LineContinue attribute="Expression" context="#pop" char="!"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="Foreach" fallthroughContext="#pop">
        <LineContinue attribute="Escape" context="#stay"/>
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectIdentifier attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Keyword" context="#pop!ForeachWord" char="("/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="ForeachWord" fallthroughContext="NormalOption">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Control" context="#stay" char=";"/>
        <DetectChar attribute="Keyword" context="#pop" char=")"/>
        <DetectChar attribute="Backquote" context="CommandBackq" char="`"/>
        <AnyChar attribute="Control" context="#stay" String="&symbolseps;"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="For" fallthroughContext="#pop">
        <LineContinue attribute="Escape" context="#stay"/>
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <WordDetect attribute="Keyword" context="#pop!CommandArgs" String="in"/>
        <DetectIdentifier attribute="Normal Text" context="#stay"/>
        <Detect2Chars attribute="Keyword" context="#pop!ForArithmeticExpr" char="(" char1="("/>
        <DetectChar attribute="Keyword" context="#pop!ForeachWord" char="("/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ForArithmeticExpr">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Control" context="#stay" char=";"/>
        <Detect2Chars attribute="Keyword" context="#pop" char=")" char1=")"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="Select" fallthroughContext="#pop">
        <LineContinue attribute="Escape" context="#stay"/>
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectIdentifier attribute="Normal Text" context="#pop!SelectIn"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="SelectIn" fallthroughContext="#pop">
        <LineContinue attribute="Escape" context="#stay"/>
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <WordDetect attribute="Keyword" context="#pop!CommandArgs" String="in"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="Repeat" fallthroughContext="#pop!RepeatArithmeticExpr">
        <LineContinue attribute="Escape" context="#stay"/>
        <DetectSpaces attribute="Normal Text" context="#stay"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="RepeatArithmeticExpr">
        <DetectSpaces attribute="Normal Text" context="#pop"/>
        <DetectChar attribute="Control" context="#pop" char=";"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>

      <!-- &> and &>> redirection -->
      <context attribute="Normal Text" lineEndContext="#pop" name="Prefix&amp;>" fallthroughContext="#pop!FdRedirection">
        <Detect2Chars attribute="Redirection" context="#pop!WordRedirection" char=">" char1="|"/>
        <Detect2Chars attribute="Redirection" context="#pop!WordRedirection" char=">" char1="!"/>
        <AnyChar attribute="Redirection" context="#pop!WordRedirection" String=">|!"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="AssumeRedirection">
        <!-- handle output redirection -->
        <StringDetect attribute="Redirection" context="#pop!WordRedirection" String=">>|"/>
        <StringDetect attribute="Redirection" context="#pop!WordRedirection" String=">>!"/>
        <StringDetect attribute="Redirection" context="#pop!WordRedirection" String=">>&amp;|"/>
        <StringDetect attribute="Redirection" context="#pop!WordRedirection" String=">>&amp;!"/>
        <StringDetect attribute="Redirection" context="#pop!ProcessSubst" String=">>("/>
        <Detect2Chars attribute="Redirection" context="#pop!WordRedirection" char=">" char1=">"/>
        <Detect2Chars attribute="Redirection" context="#pop!WordRedirection" char=">" char1="|"/>
        <Detect2Chars attribute="Redirection" context="#pop!WordRedirection" char=">" char1="!"/>
        <StringDetect attribute="Redirection" context="#pop!WordRedirection" String=">&amp;|"/>
        <StringDetect attribute="Redirection" context="#pop!WordRedirection" String=">&amp;!"/>
        <Detect2Chars attribute="Redirection" context="#pop!FdRedirection" char=">" char1="&amp;"/>
        <Detect2Chars attribute="Redirection" context="#pop!ProcessSubst" char=">" char1="("/>
        <DetectChar attribute="Redirection" context="#pop!WordRedirection" char=">"/>
        <!-- handle input redirection -->
        <Detect2Chars attribute="Redirection" context="#pop!ProcessSubst" char="&lt;" char1="("/>
        <StringDetect attribute="Redirection" context="#pop!ProcessSubst" String="&lt;&lt;("/>
        <StringDetect attribute="Redirection" context="#pop!StringRedirection" String="&lt;&lt;&lt;"/>
        <!-- handle here document -->
        <Detect2Chars context="#pop!HereDoc" char="&lt;" char1="&lt;" lookAhead="1"/>
        <Detect2Chars attribute="Redirection" context="#pop!FdRedirection" char="&lt;" char1="&amp;"/>
        <Detect2Chars attribute="Redirection" context="#pop!WordRedirection" char="&lt;" char1=">"/>
        <IncludeRules context="FindGlobRangeThenPop"/>
        <DetectChar attribute="Redirection" context="#pop!WordRedirection" char="&lt;"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="FdRedirection" fallthroughContext="#pop!FdRedirection2">
        <DetectSpaces attribute="Normal Text" context="#pop!FdRedirection2"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="FdRedirection2" fallthroughContext="#pop!WordRedirection2">
        <RegExpr attribute="File Descriptor" context="#pop!CloseFile" String="[0-9]+(?=-?&eoexpr;)"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="WordRedirection" fallthroughContext="#pop!WordRedirection2">
        <DetectSpaces attribute="Normal Text" context="#pop!WordRedirection2"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="WordRedirection2" fallthroughContext="#pop">
        <AnyChar context="#pop" String="&wordseps;`" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <RegExpr attribute="Path" context="PathThenPop" String="&path;"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="StringRedirection" fallthroughContext="#pop!StringRedirection2">
        <DetectSpaces attribute="Normal Text" context="#pop!StringRedirection2"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="StringRedirection2">
        <AnyChar context="#pop" String="&wordseps;`" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <DetectIdentifier attribute="Normal Text"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="CloseFile" fallthroughContext="#pop">
        <DetectChar attribute="Keyword" context="#pop" char="-"/>
      </context>

      <!-- HereDoc consumes Here-documents. It is called at the beginning of the "<<" construct. -->
      <context attribute="Normal Text" lineEndContext="#stay" name="HereDoc">
        <RegExpr attribute="Redirection" context="HereDocIQ"  String="&lt;&lt;-[ &tab;]*&heredocq;(?=[ &tab;]*$)"/>
        <RegExpr attribute="Redirection" context="HereDocINQ" String="&lt;&lt;-[ &tab;]*([^&wordseps;]+)(?=[ &tab;]*$)"/>
        <RegExpr attribute="Redirection" context="HereDocQ"   String="&lt;&lt;[ &tab;]*&heredocq;(?=[ &tab;]*$)"/>
        <RegExpr attribute="Redirection" context="HereDocNQ"  String="&lt;&lt;[ &tab;]*([^&wordseps;]+)(?=[ &tab;]*$)"/>

        <RegExpr context="HereDocIQCmd"  String="(&lt;&lt;-[ &tab;]*&heredocq;)" lookAhead="1"/>
        <RegExpr context="HereDocINQCmd" String="(&lt;&lt;-[ &tab;]*([^&wordseps;]+))" lookAhead="1"/>
        <RegExpr context="HereDocQCmd"   String="(&lt;&lt;[ &tab;]*&heredocq;)" lookAhead="1"/>
        <RegExpr context="HereDocNQCmd"  String="(&lt;&lt;[ &tab;]*([^&wordseps;]+))" lookAhead="1"/>

        <Detect2Chars attribute="Redirection" context="#pop"  char="&lt;" char1="&lt;"/><!-- always met -->
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="HereDocRemainder" fallthroughContext="Command">
        <IncludeRules context="Start"/>
      </context>

      <context attribute="Here Doc" lineEndContext="#stay" name="HereDocQ" dynamic="1" fallthroughContext="HereDocText">
        <RegExpr attribute="Redirection" context="#pop#pop" String="^%1$" dynamic="1" column="0"/>
      </context>

      <context attribute="Here Doc" lineEndContext="#stay" name="HereDocNQ" dynamic="1" fallthroughContext="HereDocSubstitutions">
        <RegExpr attribute="Redirection" context="#pop#pop" String="^%1$" dynamic="1" column="0"/>
      </context>

      <context attribute="Here Doc" lineEndContext="#stay" name="HereDocIQ" dynamic="1" fallthroughContext="HereDocText">
        <RegExpr attribute="Redirection" context="#pop#pop" String="^\t*%1$" dynamic="1" column="0"/>
      </context>

      <context attribute="Here Doc" lineEndContext="#stay" name="HereDocINQ" dynamic="1" fallthroughContext="HereDocSubstitutions">
        <RegExpr attribute="Redirection" context="#pop#pop" String="^\t*%1$" dynamic="1" column="0"/>
      </context>

      <context attribute="Here Doc" lineEndContext="#stay" name="HereDocQCmd" dynamic="1" fallthroughContext="HereDocText">
        <StringDetect attribute="Redirection" context="HereDocRemainder" String="%1" dynamic="1"/>
        <RegExpr attribute="Redirection" context="#pop#pop" String="^%2$" dynamic="1" column="0"/>
      </context>

      <context attribute="Here Doc" lineEndContext="#stay" name="HereDocNQCmd" dynamic="1" fallthroughContext="HereDocSubstitutions">
        <StringDetect attribute="Redirection" context="HereDocRemainder" String="%1" dynamic="1"/>
        <RegExpr attribute="Redirection" context="#pop#pop" String="^%2$" dynamic="1" column="0"/>
      </context>

      <context attribute="Here Doc" lineEndContext="#stay" name="HereDocIQCmd" dynamic="1" fallthroughContext="HereDocText">
        <StringDetect attribute="Redirection" context="HereDocRemainder" String="%1" dynamic="1"/>
        <RegExpr attribute="Redirection" context="#pop#pop" String="^\t*%2$" dynamic="1" column="0"/>
      </context>

      <context attribute="Here Doc" lineEndContext="#stay" name="HereDocINQCmd" dynamic="1" fallthroughContext="HereDocSubstitutions">
        <StringDetect attribute="Redirection" context="HereDocRemainder" String="%1" dynamic="1"/>
        <RegExpr attribute="Redirection" context="#pop#pop" String="^\t*%2$" dynamic="1" column="0"/>
      </context>

      <context attribute="Here Doc" lineEndContext="#pop" name="HereDocText">
      </context>

      <context attribute="Here Doc" lineEndContext="#pop" name="HereDocSubstitutions">
        <DetectSpaces attribute="Here Doc"/>
        <DetectIdentifier attribute="Here Doc"/>
        <DetectChar context="HereDocVariables" char="$" lookAhead="1"/>
        <DetectChar attribute="Backquote" context="CommandBackq" char="`"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
      </context>
      <context attribute="Here Doc" lineEndContext="#pop" name="HereDocVariables">
        <IncludeRules context="DispatchSubstVariables"/>
        <IncludeRules context="DispatchVarNameVariables"/>
        <DetectChar attribute="Here Doc" context="#pop" char="$"/>
      </context>

      <!-- VarName consumes spare variable names and assignments -->
      <context attribute="Normal Text" lineEndContext="#pop" name="VarName">
        <StringDetect attribute="Builtin" context="#pop!BuiltinGetopts" String="getopts"/>
        <StringDetect attribute="Builtin" context="#pop!BuiltinLet" String="let"/>
        <DetectIdentifier attribute="Builtin" context="#pop!VarNameArgs"/>
        <AnyChar attribute="Builtin" context="#pop!VarNameArgs" String=".:-"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="VarNameArgs" fallthroughContext="#pop!CommandArgs">
        <DetectSpaces attribute="Normal Text" context="VarNameArg"/>
        <LineContinue attribute="Escape" context="#stay"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop#pop" name="VarNameArg" fallthroughContext="#pop!VarNameArg2">
        <!-- In command arguments, do not allow comments after escaped characters.
             This avoids highlighting comments within paths or other text. Ex: pathtext\ #no\ comment -->
        <DetectChar context="#pop#pop" char="#" lookAhead="1"/>
        <AnyChar attribute="Option" context="#pop!ShortOption" String="-+"/>
        <DetectChar attribute="Keyword" context="#pop!VarNameArg2" char="="/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="VarNameArg2" fallthroughContext="#pop!NormalOption">
        <DetectChar attribute="Variable" context="Subscript" char="["/>
        <DetectChar attribute="Operator" context="Assign" char="="/>
        <DetectChar attribute="Variable" context="AssignArray" char="("/>
        <DetectIdentifier attribute="Variable" context="#stay"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="BuiltinGetopts" fallthroughContext="#pop!CommandArgs">
        <DetectSpaces attribute="Normal Text" context="#pop!BuiltinGetoptsOpt"/>
        <LineContinue attribute="Escape" context="#stay"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop#pop" name="BuiltinGetoptsOpt" fallthroughContext="#pop!BuiltinGetoptsOpt2">
        <DetectChar context="#pop#pop" char="#" lookAhead="1"/>
        <DetectChar attribute="Keyword" context="#pop!NormalOption" char="="/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="BuiltinGetoptsOpt2" fallthroughContext="#pop!NormalOption">
        <DetectChar attribute="Operator" context="#stay" char=":"/>
        <DetectIdentifier attribute="Normal Text" context="#stay" />
        <DetectSpaces attribute="Normal Text" context="#pop!BuiltinGetoptsVar"/>
        <AnyChar context="#pop" String="&wordseps_or_extglog;" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <DetectChar context="NormalOptionMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar context="NormalOptionMaybeGroupEnd" char="}" lookAhead="1"/>
        <AnyChar attribute="Normal Text" context="#stay" String="/%.0123456789"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="BuiltinGetoptsVar" fallthroughContext="#pop!CommandArgs">
        <DetectIdentifier attribute="Variable" context="#pop!CommandArgs"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="BuiltinLet" fallthroughContext="#pop!CommandArgs">
        <DetectSpaces attribute="Normal Text" context="#pop!BuiltinLetArgs"/>
        <LineContinue attribute="Escape" context="#stay"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="BuiltinLetArgs" fallthroughContext="BuiltinLetArg">
        <AnyChar context="BuiltinLetArgsNumber" String="0123456789" lookAhead="1"/>
        <IncludeRules context="CommandArgs"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="BuiltinLetArgsNumber" fallthroughContext="#pop!BuiltinLetArg">
        <IncludeRules context="FindRedirection"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop#pop" name="BuiltinLetArg" fallthroughContext="#pop!BuiltinLetExpr">
        <DetectChar context="#pop#pop" char="#" lookAhead="1"/>
        <DetectChar attribute="Keyword" context="#pop!NormalOption" char="="/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="BuiltinLetExpr" fallthroughContext="#pop!NormalOption">
        <DetectIdentifier attribute="Variable" context="#stay" />
        <AnyChar context="#pop" String="&wordseps_or_extglog;" lookAhead="1"/>
        <AnyChar attribute="Operator" context="#stay" String="+-!%=^:"/>
        <AnyChar context="Number" String="0123456789." lookAhead="1"/>
        <DetectChar attribute="Parameter Expansion Operator" context="Subscript" char="["/>
        <IncludeRules context="FindWord"/>
        <Detect2Chars attribute="BaseN" context="NoPrefix" char="#" char1="#"/>
        <DetectChar attribute="Error" context="#stay" char="#"/>
        <DetectChar context="NormalOptionMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar context="NormalOptionMaybeGroupEnd" char="}" lookAhead="1"/>
      </context>

      <!-- ProcessSubst handles <(command) and >(command) -->
      <context attribute="Normal Text" lineEndContext="#stay" name="ProcessSubst" fallthroughContext="Command">
        <DetectChar attribute="Redirection" context="#pop" char=")"/>
        <IncludeRules context="Start"/>
      </context>

      <!-- StringSQ consumes anything till ' -->
      <context attribute="String SingleQ" lineEndContext="#stay" name="StringSQ">
        <DetectSpaces attribute="String SingleQ"/>
        <DetectIdentifier attribute="String SingleQ"/>
        <DetectChar attribute="String SingleQ" context="#pop" char="'"/>
      </context>

      <!-- StringDQ consumes anything till ", substitutes vars and expressions -->
      <context attribute="String DoubleQ" lineEndContext="#stay" name="StringDQ">
        <DetectSpaces attribute="String DoubleQ"/>
        <DetectIdentifier attribute="String DoubleQ"/>
        <DetectChar attribute="String DoubleQ" context="#pop" char="&quot;"/>
        <DetectChar context="StringDQEscape" char="\" lookAhead="1"/>
        <DetectChar context="StringDQDispatchVariables" char="$" lookAhead="1"/>
        <DetectChar attribute="Backquote" context="RegularBackq" char="`"/>
      </context>
      <context attribute="String DoubleQ" lineEndContext="#stay" name="StringDQDispatchVariables">
        <IncludeRules context="DispatchSubstVariables"/>
        <IncludeRules context="DispatchVarNameVariables"/>
        <DetectChar attribute="String DoubleQ" context="#pop" char="$"/>
      </context>
      <context attribute="String DoubleQ" lineEndContext="#pop" name="StringDQEscape">
        <Detect2Chars attribute="String Escape" context="#pop" char="\" char1="&quot;"/>
        <Detect2Chars attribute="String Escape" context="#pop" char="\" char1="\"/>
        <Detect2Chars attribute="String Escape" context="#pop" char="\" char1="`"/>
        <Detect2Chars attribute="String Escape" context="#pop" char="\" char1="$"/>
        <LineContinue attribute="String Escape" context="#pop"/>
        <DetectChar attribute="String DoubleQ" context="#pop" char="\"/>
      </context>

      <!-- RegularBackq consumes anything till ` -->
      <context attribute="Normal Text" lineEndContext="#stay" name="RegularBackq" fallthroughContext="Command">
        <DetectChar attribute="Backquote" context="#pop" char="`"/>
        <DetectChar attribute="Comment" context="CommentBackq" char="#"/>
        <IncludeRules context="Start"/>
      </context>

      <!-- StringEsc eats till ', but escaping many characters -->
      <context attribute="String SingleQ" lineEndContext="#stay" name="StringEsc">
        <DetectSpaces attribute="String SingleQ"/>
        <DetectIdentifier attribute="String SingleQ"/>
        <DetectChar attribute="String SingleQ" context="#pop" char="'"/>
        <RegExpr attribute="String Escape" context="#stay" String="\\(?:[abefnrtv\\']|[0-7]{1,3}|x[A-Fa-f0-9]{1,2}|c.)"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="FindWord">
        <IncludeRules context="FindStrings"/>
        <DetectChar context="RegularVariable" char="$" lookAhead="1"/>
        <DetectChar attribute="Backquote" context="RegularBackq" char="`"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="RegularVariable">
        <IncludeRules context="DispatchVariables"/>
        <DetectChar attribute="Normal Text" context="#pop" char="$"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="FindStrings">
        <DetectChar attribute="String SingleQ" context="StringSQ" char="'"/>
        <DetectChar attribute="String DoubleQ" context="StringDQ" char="&quot;"/>
      </context>

      <!-- SubstCommand is called after a $( is encountered -->
      <context attribute="Normal Text" lineEndContext="#stay" name="SubstCommand" fallthroughContext="Command">
        <DetectChar attribute="Parameter Expansion" context="#pop" char=")" endRegion="subshell"/>
        <IncludeRules context="Start"/>
      </context>

      <!-- VarBraceStart is called as soon as ${ is encoutered -->
      <context attribute="Variable" lineEndContext="#pop" name="VarBraceStart" fallthroughContext="#pop!CheckVarAlt">
        <DetectChar attribute="Parameter Expansion" context="#pop!VarFlags" char="("/>
        <IncludeRules context="VarFlagsVar"/>
      </context>
      <context attribute="Variable" lineEndContext="#stay" name="VarBraceStartRecursive" fallthroughContext="#pop#pop!CheckVarAlt">
        <Detect2Chars attribute="Parameter Expansion" context="VarBraceStart" char="$" char1="{"/>
        <StringDetect context="#pop!ExprDblParenSubstOrSubstCommand" String="$((" lookAhead="1"/>
        <Detect2Chars attribute="Parameter Expansion" context="#pop!SubstCommand" char="$" char1="(" beginRegion="subshell"/>
        <DetectChar attribute="Error" context="#pop" char="$"/>
      </context>
      <context attribute="Error" lineEndContext="#stay" name="VarError">
        <DetectChar attribute="Variable" context="#pop" char="}"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="CheckVarAlt" fallthroughContext="#pop!VarError">
        <DetectChar attribute="Parameter Expansion" context="#pop" char="}"/>
        <StringDetect attribute="Parameter Expansion Operator" context="#stay" String="[@]"/>
        <StringDetect attribute="Parameter Expansion Operator" context="#stay" String="[*]"/>
        <DetectChar attribute="Parameter Expansion Operator" context="Subscript" char="["/>
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!AlternatePatternValue" char="%" char1="%"/>
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!AlternatePatternValue" char="#" char1="#"/>
        <AnyChar attribute="Parameter Expansion Operator" context="#pop!AlternatePatternValue" String="#%"/>
        <AnyChar attribute="Parameter Expansion Operator" context="#pop!AlternateValue" String="-+=?"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!AlternateValuePrefix" char=":"/>
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarBraceSubst" char="/" char1="/"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarBraceSubst" char="/"/>
      </context>
      <context attribute="Parameter Expansion" lineEndContext="#stay" name="AlternateValuePrefix" fallthroughContext="#pop!VarSub">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!AlternateValue" char="^" char1="^"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!AlternatePatternValue" char="#"/>
        <AnyChar attribute="Parameter Expansion Operator" context="#pop!AlternateValue" String="-+=?|*^"/>
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!AlternateValue" char=":" char1="="/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarBraceSubst" char="/"/>

        <!-- Modifiers -->
        <AnyChar attribute="Parameter Expansion" context="#pop!VarBraceModifiers" String="aAcehlpPqQrsg&amp;tux" lookAhead="1"/>
      </context>

      <!-- called as soon as ${xxx:y (with y a modifier) is encoutered -->
      <context attribute="Parameter Expansion" lineEndContext="#stay" name="VarBraceModifiers">
        <DetectChar attribute="Parameter Expansion" context="#pop" char="}"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#stay" char=":"/>
        <AnyChar attribute="Parameter Expansion" context="VarBraceModifier_h" String="ht"/>
        <DetectChar attribute="Parameter Expansion" context="VarBraceModifier_s" char="s"/>
        <Detect2Chars attribute="Parameter Expansion" context="VarBraceModifier_s" char="g" char1="s"/>
      </context>
      <context attribute="Parameter Expansion" lineEndContext="#stay" name="VarBraceModifier_h" fallthroughContext="#pop">
        <AnyChar attribute="Number" context="#stay" String="0123456789"/>
      </context>

      <!-- called as soon as ${xxx:s and ${xxx:gs is encoutered -->
      <context attribute="Parameter Expansion" lineEndContext="#stay" name="VarBraceModifier_s">
        <DetectChar attribute="Error" context="#pop#pop" char="}"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarBraceModifier_s_Str" char="/"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarBraceModifier_s_Str">
        <DetectChar attribute="Parameter Expansion" context="#pop#pop" char="}"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarBraceModifier_s_Rep" char="/"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <DetectChar attribute="String SingleQ" context="RecursiveVarBraceModifier_s" char="{"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="RecursiveVarBraceModifier_s">
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <DetectChar attribute="String SingleQ" context="#pop" char="}"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarBraceModifier_s_Rep">
        <DetectChar attribute="Parameter Expansion" context="#pop#pop" char="}"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="/"/>
        <DetectChar attribute="String SingleQ" context="RecursiveVarBraceModifier_s" char="{"/>
      </context>

      <!-- called as soon as ${xxx: is encoutered -->
      <context attribute="Normal Text" lineEndContext="#stay" name="VarSub">
        <DetectChar attribute="Variable" context="#pop" char="}"/>
        <AnyChar context="VarOffset" String="0123456789" lookAhead="1"/>
        <AnyChar attribute="Operator" context="#stay" String="+-!~*/%&lt;>=&amp;^|"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#stay" char=":"/>
        <DetectChar context="VarVariables" char="$" lookAhead="1"/>
        <IncludeRules context="FindStrings"/>
        <DetectChar attribute="Backquote" context="RegularBackq" char="`"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
      </context>
      <context attribute="Command" lineEndContext="#pop" name="VarVariables">
        <IncludeRules context="DispatchVariables"/>
        <DetectChar attribute="Error" context="#pop" char="$"/>
      </context>
      <context attribute="Number" lineEndContext="#pop" name="VarOffset" fallthroughContext="#pop">
        <Detect2Chars attribute="Hex" context="#pop!Hex" char="0" char1="x"/>
        <Detect2Chars attribute="Hex" context="#pop!Hex" char="0" char1="X"/>
        <AnyChar attribute="Number" context="#stay" String="0123456789_"/>
        <DetectChar attribute="Base" context="#stay" char="#"/>
      </context>

      <!-- called as soon as ${xxx:-, etc are encoutered -->
      <context attribute="String DoubleQ" lineEndContext="#stay" name="AlternateValue">
        <DetectChar attribute="String DoubleQ" context="RecursiveAlternateValue" char="{"/>
        <DetectChar attribute="Parameter Expansion" context="#pop" char="}"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindPathThenPopInAlternateValue"/>
        <DetectIdentifier attribute="String DoubleQ"/>
      </context>
      <context attribute="String DoubleQ" lineEndContext="#stay" name="RecursiveAlternateValue">
        <DetectChar attribute="String DoubleQ" context="RecursiveAlternateValue" char="{"/>
        <DetectChar attribute="String DoubleQ" context="#pop" char="}"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindPathThenPopInAlternateValue"/>
        <DetectIdentifier attribute="String DoubleQ"/>
      </context>

      <!-- called as soon as ${xxx%, etc are encoutered -->
      <context attribute="String DoubleQ" lineEndContext="#stay" name="AlternatePatternValue">
        <DetectChar attribute="String DoubleQ" context="RecursiveAlternatePatternValue" char="{"/>
        <DetectChar attribute="Parameter Expansion" context="#pop" char="}"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindStringDQPattern"/>
        <DetectIdentifier attribute="String DoubleQ"/>
      </context>
      <context attribute="String DoubleQ" lineEndContext="#stay" name="RecursiveAlternatePatternValue">
        <DetectChar attribute="String DoubleQ" context="RecursiveAlternateValue" char="{"/>
        <DetectChar attribute="String DoubleQ" context="#pop" char="}"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindStringDQPattern"/>
        <DetectIdentifier attribute="String DoubleQ"/>
      </context>

      <!-- called as soon as ${xxx/ ${xxx// ${xxx:/ are encoutered -->
      <context attribute="Normal Text" lineEndContext="#stay" name="VarBraceSubst" fallthroughContext="#pop!VarBraceSubstPat">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarBraceSubstPat" char="#" char1="%"/>
        <AnyChar attribute="Parameter Expansion Operator" context="#pop!VarBraceSubstPat" String="#%"/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="VarBraceSubstPat">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!AlternateValue" char="/"/>
        <DetectChar attribute="String DoubleQ" context="RecursiveAlternateValue" char="{"/>
        <DetectChar attribute="Parameter Expansion" context="#pop" char="}"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindSubPattern"/>
        <DetectIdentifier attribute="Pattern"/>
      </context>

      <!-- called as soon as ${( is encoutered -->
      <context attribute="Parameter Expansion" lineEndContext="#stay" name="VarFlags">
        <AnyChar attribute="Parameter Expansion Operator" context="#stay" String="#q@AabcCDefFikLnoOPqQ+-tuUvVwWXz0~mSBEMNR"/>
        <AnyChar attribute="Parameter Expansion Operator" context="VarFlag_s" String="sjgZ_"/>
        <AnyChar attribute="Parameter Expansion Operator" context="VarFlag_l" String="lrI"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlagsSubs" char="p"/>

        <DetectChar attribute="Parameter Expansion" context="#pop!VarFlagsVar" char=")"/>
        <DetectChar attribute="Error" context="#pop" char="}"/>
      </context>
      <context attribute="Parameter Expansion" lineEndContext="#stay" name="VarFlagsSubs">
        <AnyChar attribute="Parameter Expansion Operator" context="#stay" String="#q@AabcCDefFikLnoOPqQ+-tuUvVwWXz0~mSBEMNRp"/>
        <AnyChar attribute="Parameter Expansion Operator" context="VarFlag_s" String="gZ"/>
        <AnyChar attribute="Parameter Expansion Operator" context="VarFlag_ps" String="sj_"/>
        <AnyChar attribute="Parameter Expansion Operator" context="VarFlag_pl" String="lrI"/>

        <DetectChar attribute="Parameter Expansion" context="#pop!VarFlagsVar" char=")"/>
        <DetectChar attribute="Error" context="#pop" char="}"/>
      </context>
      <context attribute="Variable" lineEndContext="#stay" name="VarFlagsVar" fallthroughContext="#pop!CheckVarAlt">
        <DetectChar context="VarBraceStartRecursive" char="$" lookAhead="1"/>
        <DetectChar attribute="Parameter Expansion" context="#pop" char="}"/>
        <DetectChar attribute="String DoubleQ" context="StringDQ" char="&quot;"/>
        <AnyChar attribute="Parameter Expansion Operator" context="#stay" String="#+^=~"/>
        <DetectIdentifier attribute="Variable" context="#pop!CheckVarAlt"/>
        <AnyChar attribute="Variable" context="#pop!CheckVarAlt" String="*@?$-"/>
        <Int attribute="Variable" context="#pop!CheckVarAlt" additionalDeliminator="#~=^+{}[]:-/$"/>
        <Detect2Chars context="#pop!VarSubShell" char="!" char1="}" lookAhead="1"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!AlternateValue" char="!"/>
      </context>

      <context attribute="Parameter Expansion" lineEndContext="#stay" name="VarSubShell">
        <DetectChar attribute="Variable" context="#pop!CheckVarAlt" char="!"/>
      </context>

      <context attribute="Parameter Expansion" lineEndContext="#stay" name="VarFlag_s">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_s[" char="["/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_s&lt;" char="&lt;"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_s{" char="{"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_s(" char="("/>
        <RegExpr attribute="Parameter Expansion Operator" context="#pop!VarFlag_sx" String="(.)"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_s[">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="]"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_s&lt;">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=">"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_s{">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="}"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_s(">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=")"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_sx">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="1" dynamic="1"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_l">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_l[" char="["/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_l&lt;" char="&lt;"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_l{" char="{"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_l(" char="("/>
        <RegExpr attribute="Parameter Expansion Operator" context="#pop!VarFlag_lx" String="(.)"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_l[">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarFlag_l[s" char="]" char1="["/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="]"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_l&lt;">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarFlag_l&lt;s" char=">" char1="&lt;"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=">"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_l{">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarFlag_l{s" char="}" char1="{"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="}"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_l(">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarFlag_l(s" char=")" char1="("/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=")"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_lx">
        <RegExpr attribute="Parameter Expansion Operator" context="#pop!VarFlag_lxs" String="(%1)%1" dynamic="1"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="1" dynamic="1"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_l[s">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#stay" char="]" char1="["/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="]"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_l&lt;s">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#stay" char=">" char1="&lt;"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=">"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_l{s">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#stay" char="}" char1="{"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="}"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_l(s">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#stay" char=")" char1="("/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=")"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_lxs">
        <StringDetect attribute="Parameter Expansion Operator" context="#stay" String="%1%1" dynamic="1"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="1" dynamic="1"/>
      </context>

      <context attribute="Parameter Expansion" lineEndContext="#stay" name="VarFlag_ps">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_ps[" char="["/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_ps&lt;" char="&lt;"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_ps{" char="{"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_ps(" char="("/>
        <RegExpr attribute="Parameter Expansion Operator" context="#pop!VarFlag_psx" String="(.)"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_ps[">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="]"/>
        <RegExpr attribute="Variable" context="#stay" String="\$(&varname;|[0-9]+)(?=\])"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_ps&lt;">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=">"/>
        <RegExpr attribute="Variable" context="#stay" String="\$(&varname;|[0-9]+)(?=>)"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_ps{">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="}"/>
        <RegExpr attribute="Variable" context="#stay" String="\$(&varname;|[0-9]+)(?=})"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_ps(">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=")"/>
        <RegExpr attribute="Variable" context="#stay" String="\$(&varname;|[0-9]+)(?=\))"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_psx">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="1" dynamic="1"/>
        <RegExpr attribute="Variable" context="#stay" String="\$(?!%1)(?:[A-Za-z_](?:(?!%1)[A-Za-z0-9_])*+|(?:(?!%1)[0-9])++)(?=%1)" dynamic="1"/>
        <RegExpr attribute="String SingleQ" context="#stay" String="[^%1]+" dynamic="1"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_pl">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_pl[" char="["/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_pl&lt;" char="&lt;"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_pl{" char="{"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!VarFlag_pl(" char="("/>
        <RegExpr attribute="Parameter Expansion Operator" context="#pop!VarFlag_plx" String="(.)"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_pl[">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarFlag_pl[s" char="]" char1="["/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="]"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_pl&lt;">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarFlag_pl&lt;s" char=">" char1="&lt;"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=">"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_pl{">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarFlag_pl{s" char="}" char1="{"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="}"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_pl(">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!VarFlag_pl(s" char=")" char1="("/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=")"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="VarFlag_plx">
        <RegExpr attribute="Parameter Expansion Operator" context="#pop!VarFlag_plxs" String="(%1)%1" dynamic="1"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="1" dynamic="1"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_pl[s">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#stay" char="]" char1="["/>
        <IncludeRules context="VarFlag_ps["/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_pl&lt;s">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#stay" char=">" char1="&lt;"/>
        <IncludeRules context="VarFlag_ps&lt;"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_pl{s">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#stay" char="}" char1="{"/>
        <IncludeRules context="VarFlag_ps{"/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_pl(s">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#stay" char=")" char1="("/>
        <IncludeRules context="VarFlag_ps("/>
      </context>
      <context attribute="String SingleQ" lineEndContext="#stay" name="VarFlag_plxs">
        <StringDetect attribute="Parameter Expansion Operator" context="#stay" String="%1%1" dynamic="1"/>
        <IncludeRules context="VarFlag_psx"/>
      </context>

      <context attribute="Escape" lineEndContext="#pop" name="BraceExpansion">
        <DetectChar attribute="Escape" context="#pop!BraceExpansion2" char="{"/>
      </context>
      <context attribute="Escape" lineEndContext="#pop" name="BraceExpansion2">
        <DetectChar attribute="Operator" context="#stay" char=","/>
        <DetectChar attribute="Escape" context="#pop" char="}"/>
        <DetectChar context="EscapeMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <DetectChar attribute="Backquote" context="CommandBackq" char="`"/>
        <DetectChar context="BraceExpansionVariables" char="$" lookAhead="1"/>
        <IncludeRules context="FindStrings"/>
        <IncludeRules context="FindPattern"/>
        <DetectIdentifier attribute="Escape"/>
      </context>
      <context attribute="Escape" lineEndContext="#pop" name="EscapeMaybeBraceExpansion">
        <IncludeRules context="DispatchBraceExpansion"/>
        <DetectChar attribute="Escape" context="#pop!BraceExpansion2" char="{"/>
      </context>
      <context attribute="Escape" lineEndContext="#pop" name="BraceExpansionVariables">
        <IncludeRules context="DispatchVariables"/>
        <DetectChar attribute="Escape" context="#pop" char="$"/>
      </context>

      <context attribute="Escape" lineEndContext="#pop" name="PathBraceExpansion">
        <DetectChar attribute="Escape" context="#pop!PathBraceExpansion2" char="{"/>
      </context>
      <context attribute="Path" lineEndContext="#pop" name="PathBraceExpansion2">
        <DetectChar attribute="Operator" context="#stay" char=","/>
        <DetectChar attribute="Escape" context="#pop" char="}"/>
        <DetectChar context="PathMaybeBraceExpansion" char="{" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindPattern"/>
        <DetectIdentifier attribute="Path"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="SequenceExpression">
        <AnyChar attribute="Number" context="#stay" String="0123456789-"/>
        <IncludeRules context="FindWord"/>
        <Detect2Chars attribute="Escape" context="#stay" char="." char1="."/>
        <DetectChar attribute="Escape" context="#pop" char="}"/>
      </context>

<!-- ====== These are the contexts that can be branched to ======= -->

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblParenOrSubShell">
        <RegExpr attribute="Keyword" context="#pop!SubShell" String="\((?=&arithmetic_as_subshell;)|" beginRegion="subshell"/>
        <Detect2Chars attribute="Keyword" context="#pop!ExprDblParen" char="(" char1="(" beginRegion="expression"/>
      </context>
      <!-- ExprDblParen consumes an expression started in command mode till )) -->
      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblParen">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <Detect2Chars attribute="Keyword" context="#pop" char=")" char1=")" endRegion="expression"/>
        <IncludeRules context="FindExprDblParen"/>
        <!-- ((cmd
              ) # jump to SubShell context -->
        <DetectChar attribute="Keyword" context="#pop!SubShell" char=")" endRegion="expression" beginRegion="subshell"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="FindExprDblParen">
        <Detect2Chars attribute="Control" context="#stay" char="&amp;" char1="&amp;"/>
        <Detect2Chars attribute="Control" context="#stay" char="|" char1="|"/>
        <AnyChar attribute="Operator" context="#stay" String="+-!~*/%&lt;>=&amp;^|?:"/>
        <DetectChar attribute="Control" context="#stay" char=","/>
        <DetectChar attribute="Normal Text" context="ExprSubDblParen" char="("/>
        <AnyChar context="Number" String="0123456789." lookAhead="1"/>
        <DetectChar attribute="Parameter Expansion Operator" context="Subscript" char="["/>
        <IncludeRules context="FindWord"/>
        <DetectChar context="MaybeArithmeticBrace" char="{" lookAhead="1"/>
        <Detect2Chars attribute="BaseN" context="NoPrefix" char="#" char1="#"/>
        <DetectChar attribute="Error" context="#stay" char="#"/>
        <DetectIdentifier attribute="Variable" context="#stay"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="ExprSubDblParen">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Normal Text" context="#pop" char=")"/>
        <IncludeRules context="FindExprDblParen"/>
      </context>
      <context attribute="Error" lineEndContext="#pop" name="MaybeArithmeticBrace">
        <IncludeRules context="DispatchBraceExpansion"/>
        <DetectChar attribute="Error" context="#pop" char="{"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="NoPrefix" fallthroughContext="#pop">
        <DetectChar context="AssumeEscape" char="\"/>
        <RegExpr attribute="Number" context="#pop" String="[^][()]"/>
      </context>

      <context attribute="Number" lineEndContext="#pop" name="Number">
        <Detect2Chars attribute="Hex" context="#pop!Hex" char="0" char1="x"/>
        <Detect2Chars attribute="Hex" context="#pop!Hex" char="0" char1="X"/>
        <RegExpr attribute="Base" context="#pop!BaseN" String="[1-9][0-9_]*+#"/>
        <RegExpr attribute="Number" context="#pop" String="&int;(\.(&int;&exp;?+|&exp;)?|&exp;)?|\.&int;&exp;?"/>
        <DetectChar attribute="Operator" context="#pop" char="."/>
      </context>
      <context attribute="Hex" lineEndContext="#pop" name="Hex" fallthroughContext="#pop">
        <RegExpr attribute="Hex" context="#pop" String="[0-9a-fA-F_]+"/>
      </context>
      <context attribute="BaseN" lineEndContext="#pop" name="BaseN" fallthroughContext="#pop">
        <RegExpr attribute="BaseN" context="#pop" String="[0-9a-zA-Z@_]+"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblParenSubstOrSubstCommand">
        <RegExpr attribute="Parameter Expansion" context="#pop!SubstCommand" String="\$\((?=&arithmetic_as_subshell;)|" beginRegion="subshell"/>
        <StringDetect attribute="Parameter Expansion" context="#pop!ExprDblParenSubst" String="$((" beginRegion="expression"/>
      </context>
      <!-- ExprDblParenSubst like ExprDblParen but matches )) as Variable -->
      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblParenSubst">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <Detect2Chars attribute="Variable" context="#pop" char=")" char1=")" endRegion="expression"/>
        <IncludeRules context="FindExprDblParen"/>
        <!-- $((cmd
              ) # jump to SubstCommand context -->
        <DetectChar attribute="Parameter Expansion" context="#pop!SubstCommand" char=")" endRegion="expression" beginRegion="subshell"/>
      </context>

      <!-- ExprBracket consumes an expression till ] -->
      <context attribute="Normal Text" lineEndContext="#stay" name="ExprBracket" fallthroughContext="#pop!ExprBracketNot">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <IncludeRules context="FindExprBracketEnd"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprBracketNot" fallthroughContext="#pop!ExprBracketParam1">
        <DetectSpaces attribute="Normal Text" context="#pop!ExprBracketParam1"/>
        <Detect2Chars attribute="Expression" context="ExprBracketTestMaybeNot" char="!" char1=" " lookAhead="1"/>
        <Detect2Chars attribute="Expression" context="ExprBracketTestMaybeNot" char="!" char1="&tab;" lookAhead="1"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprBracketTestMaybeNot">
        <DetectChar attribute="Expression" context="#pop" char="!"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprBracketParam1" fallthroughContext="ExprBracketValue">
        <DetectSpaces attribute="Normal Text" context="#pop!ExprBracketParam2"/>
        <DetectChar context="TestMaybeUnary" char="-" lookAhead="1"/>
        <IncludeRules context="FindExprBracketEnd"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="ExprBracketValue">
        <AnyChar context="#pop" String=" &tab;" lookAhead="1"/>
        <AnyChar attribute="Error" context="#stay" String="&symbolseps;"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindGlobAny"/>
        <IncludeRules context="FindPathThenPop"/>
        <DetectChar context="ExprBracketValueMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar context="NormalOptionMaybeGroupEnd" char="}" lookAhead="1"/>
        <DetectIdentifier attribute="Normal Text"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprBracketValueRecBrace">
        <AnyChar context="#pop#pop" String=" &tab;" lookAhead="1"/>
        <AnyChar attribute="Error" context="#stay" String="&symbolseps;"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindGlobAny"/>
        <DetectChar context="ExprBracketValueMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar attribute="Normal Text" context="#pop" char="}"/>
        <DetectIdentifier attribute="Normal Text"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprBracketValueMaybeBraceExpansion">
        <IncludeRules context="DispatchBraceExpansion"/>
        <DetectChar attribute="Normal Text" context="#pop!ExprBracketValueRecBrace" char="{"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprBracketParam2" fallthroughContext="ExprBracketValue">
        <DetectSpaces attribute="Normal Text" context="#pop!ExprBracketParam3"/>
        <AnyChar context="TestMaybeBinary" String="-=!" lookAhead="1"/>
        <IncludeRules context="FindExprBracketEnd"/>
      </context>

      <context attribute="Normal Text" lineEndContext="ExprBracketFinal" name="ExprBracketParam3" fallthroughContext="ExprBracketValue">
        <DetectSpaces attribute="Normal Text" context="#pop!ExprBracketFinal"/>
        <IncludeRules context="FindExprBracketEnd"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprBracketFinal" fallthroughContext="ExprBracketValue">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <IncludeRules context="FindExprBracketEnd"/>
        <RegExpr attribute="Error" context="#pop" String="(?:[^] &tab;]++|\][^ &tab;])++" endRegion="expression"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="FindExprBracketEnd">
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <RegExpr attribute="Builtin" context="#pop" String="\](?=($|[ &tab;;|&amp;&lt;>)]))" endRegion="expression"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeUnary" fallthroughContext="#pop!ExprBracketValue">
        <RegExpr attribute="Expression" context="#pop" String="&unary_operators;"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeBinary" fallthroughContext="#pop!ExprBracketValue">
        <RegExpr attribute="Expression" context="#pop" String="&binary_operators;"/>
      </context>


      <!-- ExprDblBracket consumes an expression till ]] -->
      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracket" fallthroughContext="#pop!ExprDblBracketNot">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <IncludeRules context="FindExprDblBracketEnd"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketNot" fallthroughContext="#pop!ExprDblBracketParam1">
        <DetectChar context="ExprDblBracketTestMaybeNot" char="!" lookAhead="1"/>
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketTestMaybeNot" fallthroughContext="#pop#pop!ExprDblBracketParam1">
        <RegExpr attribute="Expression" context="#pop" String="!(?=$|[ &tab;(])"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam1" fallthroughContext="#pop!ExprDblBracketParam1_2">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam1_2" fallthroughContext="ExprDblBracketValueText">
        <DetectSpaces attribute="Normal Text" context="#pop!ExprDblBracketParam2"/>
        <DetectChar context="TestMaybeUnary2" char="-" lookAhead="1"/>
        <DetectChar context="ExprDblBracketSubValue" char="(" lookAhead="1"/>
        <IncludeRules context="FindExprDblBracketEnd"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeUnary2" fallthroughContext="#pop!ExprDblBracketValueText">
        <RegExpr attribute="Expression" context="#pop!ExprDblBracketUnary" String="&unary_operators;(?!\s+(?:=~|&binary_operators;))"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketUnary" fallthroughContext="#pop!ExprDblBracketValueText">
        <DetectSpaces attribute="Normal Text"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketSubValue" fallthroughContext="#pop">
        <DetectChar attribute="Operator" context="ExprDblBracketNot" char="("/>
        <DetectChar attribute="Operator" context="#pop" char=")"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketValueText" fallthroughContext="#pop!ExprDblBracketValueText2">
        <Detect2Chars context="#pop!ExprDblBracketValueTextMaybeEnd" char="]" char1="]" lookAhead="1"/>
        <IncludeRules context="FindExprDblBracketValueTextPath"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="FindExprDblBracketValueTextPath">
        <RegExpr context="#pop!ExprDblBracketValueTextPath" String="&path_with_sep;|" lookAhead="1"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketValueTextMaybeEnd">
        <RegExpr attribute="Keyword" context="#pop#pop" String="&dblbracket_close;" endRegion="expression"/>
        <IncludeRules context="FindExprDblBracketValueTextPath"/>
        <Detect2Chars context="#pop!ExprDblBracketValueText2" char="]" char1="]" lookAhead="1"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketValueText2">
        <DetectIdentifier/>
        <AnyChar String="*?+@~^:%+-/,"/>
        <Detect2Chars attribute="Control" context="#pop#pop!ExprDblBracket" char="&amp;" char1="&amp;"/>
        <Detect2Chars attribute="Control" context="#pop#pop!ExprDblBracket" char="|" char1="|"/>
        <AnyChar context="#pop" String=" &tab;)" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindGroupPattern"/>
        <AnyChar attribute="Error" context="#stay" String="&amp;;|"/>
        <DetectChar context="ExprDblBracketValueTextMaybeRange" char="&lt;" lookAhead="1"/>
        <DetectChar attribute="Expression" context="#pop!ExprDblBracketValuePattern" char=">"/>
      </context>
      <context attribute="Path" lineEndContext="#pop" name="ExprDblBracketValueTextPath">
        <IncludeRules context="ExprDblBracketValueText2"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketValueTextMaybeRange">
        <RegExpr context="#pop" String="&globrange;"/>
        <DetectChar attribute="Expression" context="#pop#pop!ExprDblBracketValuePattern" char="&lt;"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketValuePattern" fallthroughContext="#pop!ExprDblBracketValuePattern2">
        <RegExpr context="ExprDblBracketValuePatternPath" String="&path_with_sep;|" lookAhead="1"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketValuePatternPath" fallthroughContext="#pop!PathThenPop">
        <DetectChar attribute="Path" context="#pop!PathThenPop" char="~"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketValuePattern2">
        <DetectIdentifier attribute="Normal Text"/>
        <Detect2Chars attribute="Control" context="#pop#pop!ExprDblBracket" char="&amp;" char1="&amp;"/>
        <Detect2Chars attribute="Control" context="#pop#pop!ExprDblBracket" char="|" char1="|"/>
        <AnyChar context="#pop" String=" &tab;)" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindSingleGlob"/>
        <IncludeRules context="FindGlobAny"/>
        <IncludeRules context="FindGroupPattern"/>
        <DetectChar context="ExprDblBracketValueMaybeGlobRange" char="&lt;" lookAhead="1"/>
        <AnyChar attribute="Error" context="#stay" String=">&amp;|;"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketValueMaybeGlobRange">
        <IncludeRules context="FindGlobRangeThenPop"/>
        <DetectChar attribute="Error" context="#pop" char="&lt;"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam2" fallthroughContext="#pop!ExprDblBracketParam2_2">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam2_2" fallthroughContext="ExprDblBracketValuePattern">
        <DetectSpaces attribute="Normal Text" context="#pop!ExprDblBracketParam3"/>
        <AnyChar context="TestMaybeBinary2" String="-=!" lookAhead="1"/>
        <AnyChar attribute="Expression" context="#pop!ExprDblBracketParam3Spe" String="&lt;>"/>
        <IncludeRules context="FindExprDblBracketEnd"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeBinary2" fallthroughContext="#pop!ExprDblBracketValuePattern">
        <IncludeRules context="TestMaybeBinary"/>
        <RegExpr attribute="Expression" context="#pop#pop!ExprDblBracketRegex" String="=~&eos;"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam3Spe" fallthroughContext="#pop!ExprDblBracketParam3">
        <DetectSpaces attribute="Normal Text" context="#pop!ExprDblBracketParam3"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam3" fallthroughContext="#pop!ExprDblBracketParam3_2">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop!ExprDblBracketFinal" name="ExprDblBracketParam3_2" fallthroughContext="ExprDblBracketValuePattern">
        <DetectSpaces attribute="Normal Text" context="#pop!ExprDblBracketFinal"/>
        <IncludeRules context="FindExprDblBracketEnd"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketFinal" fallthroughContext="ExprDblBracketValuePattern">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <IncludeRules context="FindExprDblBracketEnd"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
        <RegExpr attribute="Error" context="#pop" String="(?:[^] &tab;]++|\](?:[^]]|\][^ &tab;]))++" endRegion="expression"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="FindExprDblBracketEnd">
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <DetectChar context="#pop" char=")" lookAhead="1"/>
        <Detect2Chars attribute="Control" context="#pop!ExprDblBracket" char="&amp;" char1="&amp;"/>
        <Detect2Chars attribute="Control" context="#pop!ExprDblBracket" char="|" char1="|"/>
        <RegExpr attribute="Keyword" context="#pop" String="&dblbracket_close;" endRegion="expression"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketRegex" fallthroughContext="#pop!Regex">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="Regex">
        <DetectIdentifier attribute="Pattern"/>
        <DetectSpaces attribute="Normal Text" context="#pop!ExprDblBracketFinal"/>
        <DetectChar attribute="Operator" context="#pop" char=")"/>
        <Detect2Chars attribute="Operator" context="RegexChar" char="[" char1="^"/>
        <DetectChar attribute="Operator" context="RegexChar" char="["/>
        <IncludeRules context="FindRegex"/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="ExprDblBracketSubRegex">
        <DetectIdentifier attribute="Pattern"/>
        <DetectSpaces attribute="Pattern" context="#stay"/>
        <DetectChar attribute="Operator" context="#pop" char=")"/>
        <Detect2Chars attribute="Operator" context="RegexSubChar" char="[" char1="^"/>
        <DetectChar attribute="Operator" context="RegexSubChar" char="["/>
        <IncludeRules context="FindRegex"/>
      </context>

      <context attribute="Pattern" lineEndContext="#stay" name="FindRegex">
        <DetectChar attribute="Operator" context="ExprDblBracketSubRegex" char="("/>
        <DetectChar attribute="Escape" context="RegexEscape" char="\"/>
        <DetectChar attribute="Parameter Expansion" context="RegexDup" char="{"/>
        <AnyChar attribute="Glob" context="#stay" String="^?+*.|"/>
        <IncludeRules context="FindStrings"/>
        <DetectChar context="RegexDispatchVariables" char="$" lookAhead="1"/>
        <DetectChar attribute="Backquote" context="RegularBackq" char="`"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="RegexDispatchVariables">
        <IncludeRules context="DispatchVariables"/>
        <DetectChar attribute="Operator" context="#pop" char="$"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="RegexEscape">
        <RegExpr attribute="Escape" context="#pop" String="x[0-9a-fA-F]{1,2}|[0-7]{1,3}|."/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="RegexDup">
        <Int attribute="Number"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#stay" char=","/>
        <DetectChar attribute="Parameter Expansion" context="#pop" char="}"/>
      </context>

      <context attribute="Pattern" lineEndContext="#pop" name="RegexSubChar" fallthroughContext="#pop!RegexSubInChar">
        <AnyChar attribute="Pattern" context="#pop!RegexSubInChar" String="-]"/>
      </context>
      <context attribute="Pattern" lineEndContext="#pop" name="RegexSubInChar">
        <DetectSpaces attribute="Pattern" context="#stay"/>
        <IncludeRules context="RegexInChar"/>
      </context>

      <context attribute="Pattern" lineEndContext="#pop" name="RegexChar" fallthroughContext="#pop!RegexInChar">
        <AnyChar attribute="Pattern" context="#pop!RegexInChar" String="-]"/>
      </context>
      <context attribute="Pattern" lineEndContext="#pop" name="RegexInChar">
        <Detect2Chars context="RegexInCharEnd" char="-" char1="]" lookAhead="1"/>
        <DetectChar attribute="Operator" context="#stay" char="-"/>
        <DetectChar attribute="Escape" context="RegexEscape" char="\"/>
        <DetectChar context="RegexCharClassSelect" char="[" lookAhead="1"/>
        <DetectChar attribute="Operator" context="#pop" char="]"/>
        <AnyChar context="#pop" String="() &tab;" lookAhead="1"/>
        <IncludeRules context="FindStrings"/>
      </context>
      <context attribute="Operator" lineEndContext="#stay" name="RegexInCharEnd">
        <DetectChar attribute="Pattern" context="#stay" char="-"/>
        <DetectChar attribute="Operator" context="#pop#pop" char="]"/>
      </context>
      <context attribute="Parameter Expansion" lineEndContext="#pop#pop#pop" name="RegexCharClassSelect">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!RegexCharClass" char="[" char1=":"/>
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!RegexCollatingSymbols" char="[" char1="."/>
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!RegexEquivalenceClass" char="[" char1="="/>
        <DetectChar attribute="Pattern" context="#pop" char="["/>
      </context>

      <context attribute="Parameter Expansion" lineEndContext="#pop#pop#pop" name="RegexCharClass">
        <DetectIdentifier attribute="Parameter Expansion"/>
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop" char=":" char1="]"/>
        <DetectChar attribute="Error" context="#pop" char="]"/>
      </context>
      <context attribute="Parameter Expansion" lineEndContext="#pop#pop#pop" name="RegexCollatingSymbols">
        <DetectIdentifier attribute="Parameter Expansion"/>
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop" char="." char1="]"/>
        <DetectChar attribute="Error" context="#pop" char="]"/>
      </context>
      <context attribute="Parameter Expansion" lineEndContext="#pop#pop#pop" name="RegexEquivalenceClass">
        <DetectIdentifier attribute="Parameter Expansion"/>
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop" char="=" char1="]"/>
        <DetectChar attribute="Error" context="#pop" char="]"/>
      </context>

      <!-- SubShell consumes shell input till ) -->
      <context attribute="Normal Text" lineEndContext="#stay" name="SubShell" fallthroughContext="Command">
        <DetectChar attribute="Keyword" context="#pop" char=")" endRegion="subshell"/>
        <IncludeRules context="Start"/>
      </context>

      <!-- Assign consumes an expression till EOL or whitespace -->
      <context attribute="Normal Text" lineEndContext="#pop" name="Assign" fallthroughContext="#pop!RegularAssign">
        <DetectChar attribute="Variable" context="#pop!AssignArray" char="("/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="RegularAssign" fallthroughContext="#pop">
        <DetectChar attribute="Backquote" context="RegularBackq" char="`"/>
        <IncludeRules context="NormalOption"/>
      </context>

      <!-- AssignArray consumes everything till ), marking assignments -->
      <context attribute="Normal Text" lineEndContext="#stay" name="AssignArray" fallthroughContext="NormalOption">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
        <DetectChar attribute="Variable" context="#pop" char=")"/>
        <DetectChar context="AssignArrayKey" char="[" lookAhead="1"/>
        <DetectChar attribute="Backquote" context="AssignArrayBackq" char="`"/>
        <AnyChar attribute="Error" context="#stay" String="&symbolseps;"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="AssignArrayKey" fallthroughContext="#pop">
        <DetectChar attribute="Parameter Expansion Operator" context="Subscript" char="["/>
        <DetectChar attribute="Variable" context="#pop" char="="/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="AssignArrayBackq" fallthroughContext="Command">
        <DetectChar attribute="Backquote" context="#pop!NormalOption" char="`"/>
        <DetectChar attribute="Comment" context="CommentBackq" char="#"/>
        <IncludeRules context="Start"/>
      </context>

      <!-- Subscript consumes anything till ], marks as Variable -->
      <context attribute="Normal Text" lineEndContext="#stay" name="Subscript" fallthroughContext="Subscript2">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="]"/>
        <AnyChar attribute="Number" context="#stay" String="0123456789-"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="Subscript2">
        <DetectIdentifier attribute="Normal Text"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop#pop" char="]"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char=","/>
        <IncludeRules context="FindGroupPattern"/>
        <IncludeRules context="FindStrings"/>
        <DetectChar context="VariableOrSubscriptPos" char="$" lookAhead="1"/>
        <DetectChar attribute="Backquote" context="RegularBackq" char="`"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <AnyChar attribute="Operator" context="#pop" String="@+-!~*/%&lt;>=&amp;^|?:"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#pop" name="VariableOrSubscriptPos">
        <IncludeRules context="DispatchVariables"/>
        <DetectChar attribute="Number" context="#pop" char="$"/>
      </context>

      <!-- FunctionDef consumes a name, possibly with (), marks as Function -->
      <context attribute="Function" lineEndContext="#pop" name="FunctionDef" fallthroughContext="#pop">
        <Detect2Chars attribute="Operator" context="#pop" char="(" char1=")"/>
        <DetectSpaces attribute="Normal Text" context="FunctionNameStart"/>
      </context>
      <context attribute="Function" lineEndContext="#pop" name="FunctionNameStart" fallthroughContext="#pop!FunctionName">
        <AnyChar context="#pop#pop" String="&symbolseps;#" lookAhead="1"/>
        <DetectChar context="FunctionNameStartMaybeBraceExpansion" char="{" lookAhead="1"/>
      </context>
      <context attribute="Function" lineEndContext="#pop" name="FunctionName">
        <AnyChar context="#pop" String=" &tab;(" lookAhead="1"/>
        <IncludeRules context="FindWord"/>
        <DetectChar context="FunctionNameMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar context="NormalOptionMaybeGroupEnd" char="}" lookAhead="1"/>
        <DetectIdentifier attribute="Function"/>
      </context>
      <context attribute="Function" lineEndContext="#pop" name="FunctionNameRecBrace" fallthroughContext="#pop">
        <IncludeRules context="FindWord"/>
        <DetectChar context="FunctionNameMaybeBraceExpansion" char="{" lookAhead="1"/>
        <DetectChar attribute="Function" context="#pop" char="}"/>
        <DetectIdentifier attribute="Function"/>
      </context>
      <context attribute="Function" lineEndContext="#pop" name="FunctionNameStartMaybeBraceExpansion">
        <IncludeRules context="DispatchBraceExpansion"/>
        <DetectChar attribute="Keyword" context="#pop#pop#pop!Group" char="{"/>
      </context>
      <context attribute="Function" lineEndContext="#pop" name="FunctionNameMaybeBraceExpansion">
        <IncludeRules context="DispatchBraceExpansion"/>
        <DetectChar attribute="Function" context="#pop!FunctionNameRecBrace" char="{"/>
      </context>

      <!-- Case is called after the case keyword is encoutered. We handle this because of
           the lonely closing parentheses that would otherwise disturb the expr matching -->
      <context attribute="Normal Text" lineEndContext="#stay" name="Case">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Keyword" context="#pop!CaseAlt" char="{"/>
        <WordDetect attribute="Keyword" context="#pop!CaseIn" String="in"/>
        <IncludeRules context="FindWord"/>
        <DetectIdentifier attribute="Normal Text" context="#stay"/>
      </context>

      <!-- CaseIn is called when the construct 'case ... in' has been found. -->
      <context attribute="Normal Text" lineEndContext="#stay" name="CaseIn" fallthroughContext="CasePattern">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Keyword" context="CaseClosedPattern" char="("/>
        <DetectChar attribute="Comment" context="Comment" char="#"/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="CasePattern">
        <WordDetect attribute="Control Flow" context="#pop#pop" String="esac" endRegion="case"/>
        <IncludeRules context="CaseClosedPattern"/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="CaseClosedPattern">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Keyword" context="#pop!CaseExpr" char=")" beginRegion="caseexpr"/>
        <DetectChar context="AssumeEscape" char="\" lookAhead="1"/>
        <DetectChar attribute="Keyword" context="#stay" char="|"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindPattern"/>
        <DetectIdentifier attribute="Pattern" context="#stay"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="CaseAlt" fallthroughContext="CasePattern">
        <DetectSpaces attribute="Normal Text" context="#stay"/>
        <DetectChar attribute="Keyword" context="CasePattern" char="("/>
        <DetectChar attribute="Keyword" context="#pop!CaseAltEnd" char="}" endRegion="caseexpr" lookAhead="1"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="CaseAltEnd">
        <DetectChar attribute="Keyword" context="#pop" char="}" endRegion="case"/>
      </context>

      <!-- CaseExpr eats shell input till ;; / ;& / ;| -->
      <context attribute="Normal Text" lineEndContext="#stay" name="CaseExpr" fallthroughContext="Command">
        <Detect2Chars attribute="Control Flow" context="#pop" char=";" char1="|" endRegion="caseexpr"/>
        <Detect2Chars attribute="Control Flow" context="#pop" char=";" char1=";" endRegion="caseexpr"/>
        <Detect2Chars attribute="Control Flow" context="#pop" char=";" char1="&amp;" endRegion="caseexpr"/>
        <WordDetect context="#pop" String="esac" endRegion="caseexpr" lookAhead="1"/>
        <DetectChar context="#pop" char="}" lookAhead="1"/>
        <IncludeRules context="Start"/>
      </context>

      <!-- ExprGlobParen is called after a ( is encountered in a argument -->
      <context attribute="Glob Flag" lineEndContext="#pop" name="ExprGlobParen" fallthroughContext="#pop">
        <Detect2Chars attribute="Glob Flag" context="#pop!GlobPatFlag" char="(" char1="#"/>
        <RegExpr attribute="Glob" context="#pop!ExtGlobPattern" String="\((?=&ispattern;)"/>
        <DetectChar attribute="Glob Flag" context="#pop!GlobQualifier" char="("/>
      </context>
      <context attribute="Glob Flag" lineEndContext="#pop" name="ExprGlobParenThenPath" fallthroughContext="#pop">
        <Detect2Chars attribute="Glob Flag" context="#pop!GlobPatFlagThenPath" char="(" char1="#"/>
        <RegExpr attribute="Glob" context="#pop!ExtGlobPatternThenPath" String="\((?=&ispattern;)"/>
        <DetectChar attribute="Glob Flag" context="#pop!GlobQualifier" char="("/>
      </context>
      <context attribute="Glob Flag" lineEndContext="#pop" name="GlobQualifier">
        <AnyChar attribute="Glob Flag" context="#stay" String="/F.@=p*%bcrwxAIERWXsStUG^-MTNDn"/>
        <AnyChar attribute="Glob Flag" context="GlobQualifier_e" String="eP"/>
        <AnyChar attribute="Glob Flag" context="GlobQualifier_u" String="ug"/>
        <AnyChar attribute="Glob Flag" context="GlobQualifier_a" String="amc"/>
        <AnyChar attribute="Glob Flag" context="GlobQualifier_o" String="oO"/>
        <DetectChar attribute="Glob Flag" context="GlobQualifier_f" char="f"/>
        <DetectChar attribute="Glob Flag" context="GlobQualifier_+" char="+"/>
        <DetectChar attribute="Glob Flag" context="GlobQualifier_d" char="d"/>
        <DetectChar attribute="Glob Flag" context="GlobQualifier_L" char="L"/>
        <DetectChar attribute="Glob Flag" context="GlobQualifier_Y" char="Y"/>
        <DetectChar attribute="Parameter Expansion Operator" context="Subscript" char="["/>

        <DetectChar attribute="Operator" context="#stay" char=","/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!GlobModifier" char=":"/>
        <DetectChar attribute="Glob Flag" context="#pop" char=")"/>
        <IncludeRules context="FindWord"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#pop" name="GlobQualifier_o" fallthroughContext="#pop">
        <AnyChar attribute="Normal Text" context="#stay" String="nLlamcdN"/>
      </context>

      <context attribute="Number" lineEndContext="#pop" name="GlobQualifier_Y" fallthroughContext="#pop">
        <AnyChar attribute="Number" context="#stay" String="0123456789"/>
      </context>

      <context attribute="Glob Flag" lineEndContext="#pop" name="GlobQualifier_L" fallthroughContext="#pop">
        <AnyChar attribute="Normal Text" context="#stay" String="kKmMpPgGtT"/>
        <AnyChar attribute="Number" context="#pop!GlobQualifier_Y" String="-+0123456789"/>
      </context>

      <context attribute="Glob Flag" lineEndContext="#pop" name="GlobQualifier_a" fallthroughContext="#pop">
        <AnyChar attribute="Normal Text" context="#stay" String="Mwhmsd"/>
        <AnyChar attribute="Number" context="#pop!GlobQualifier_Y" String="-+0123456789"/>
      </context>

      <context attribute="Glob Flag" lineEndContext="#pop" name="GlobQualifier_+" fallthroughContext="#pop">
        <RegExpr attribute="Function" context="#pop" String="[^&_fragpathseps;=,\[]+"/>
      </context>

      <context attribute="Path" lineEndContext="#pop" name="GlobQualifier_d">
        <AnyChar context="#pop" String=")," lookAhead="1"/>
      </context>

      <context attribute="Glob Flag" lineEndContext="#pop" name="GlobQualifier_u">
        <AnyChar attribute="Number" context="#pop!GlobQualifier_Y" String="0123456789"/>
        <IncludeRules context="GlobQualifier_e"/>
      </context>

      <context attribute="Glob Flag" lineEndContext="#pop" name="GlobQualifier_f" fallthroughContext="#pop">
        <AnyChar attribute="Number" context="#pop!GlobQualifier_fo" String="0123456789=+-"/>
        <DetectChar attribute="Glob" context="#pop!GlobQualifier_fo" char="?"/>
        <DetectChar attribute="Glob Flag" context="#pop!GlobQualifier_f[" char="["/>
        <DetectChar attribute="Glob Flag" context="#pop!GlobQualifier_f&lt;" char="&lt;"/>
        <DetectChar attribute="Glob Flag" context="#pop!GlobQualifier_f{" char="{"/>
        <RegExpr attribute="Glob Flag" context="#pop!GlobQualifier_fx" String="(.)"/>
      </context>
      <context attribute="Number" lineEndContext="#pop" name="GlobQualifier_fo" fallthroughContext="#pop">
        <AnyChar attribute="Number" context="#stay" String="0123456789"/>
        <DetectChar attribute="Glob" context="#stay" char="?"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="GlobQualifier_f[">
        <DetectChar attribute="Operator" context="#stay" char=","/>
        <DetectChar attribute="Glob Flag" context="#pop" char="]"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="GlobQualifier_f&lt;">
        <DetectChar attribute="Operator" context="#stay" char=","/>
        <DetectChar attribute="Glob Flag" context="#pop" char=">"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="GlobQualifier_f{">
        <DetectChar attribute="Operator" context="#stay" char=","/>
        <DetectChar attribute="Glob Flag" context="#pop" char="}"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="GlobQualifier_fx">
        <DetectChar attribute="Operator" context="#stay" char=","/>
        <DetectChar attribute="Glob Flag" context="#pop" char="1" dynamic="1"/>
      </context>

      <context attribute="Glob Flag" lineEndContext="#pop" name="GlobQualifier_e" fallthroughContext="#pop">
        <DetectChar attribute="Glob Flag" context="#pop!GlobQualifier_e[" char="["/>
        <DetectChar attribute="Glob Flag" context="#pop!GlobQualifier_e&lt;" char="&lt;"/>
        <DetectChar attribute="Glob Flag" context="#pop!GlobQualifier_e{" char="{"/>
        <RegExpr attribute="Glob Flag" context="#pop!GlobQualifier_ex" String="(.)"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="IncGlobQualifier_e">
        <IncludeRules context="FindStrings"/>
        <DetectChar context="RegularVariable" char="$" lookAhead="1"/>
        <DetectChar attribute="Backquote" context="RegularBackq" char="`"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="GlobQualifier_e[">
        <DetectChar attribute="Glob Flag" context="#pop" char="]"/>
        <IncludeRules context="IncGlobQualifier_e"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="GlobQualifier_e&lt;">
        <DetectChar attribute="Glob Flag" context="#pop" char=">"/>
        <IncludeRules context="IncGlobQualifier_e"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="GlobQualifier_e{">
        <DetectChar attribute="Glob Flag" context="#pop" char="}"/>
        <IncludeRules context="IncGlobQualifier_e"/>
      </context>
      <context attribute="Normal Text" lineEndContext="#stay" name="GlobQualifier_ex">
        <DetectChar attribute="Glob Flag" context="#pop" char="1" dynamic="1"/>
        <IncludeRules context="IncGlobQualifier_e"/>
      </context>

      <!-- GlobPatFlag is called after a (# is encountered -->
      <context attribute="Glob Flag" lineEndContext="#pop" name="GlobPatFlag" fallthroughContext="#pop">
        <IncludeRules context="IncGlobPatFlag"/>
        <DetectChar attribute="Glob Flag" context="#pop" char=")"/>
      </context>
      <context attribute="Glob Flag" lineEndContext="#pop" name="GlobPatFlagThenPath" fallthroughContext="#pop">
        <IncludeRules context="IncGlobPatFlag"/>
        <DetectChar attribute="Glob Flag" context="#pop!PathThenPop" char=")"/>
      </context>
      <context attribute="Glob Flag" lineEndContext="#pop" name="IncGlobPatFlag" fallthroughContext="#pop">
        <AnyChar attribute="Glob Flag" context="#stay" String="ilIbBcmMaseuU,"/>
        <AnyChar attribute="Number" context="#stay" String="0123456789"/>
        <DetectChar attribute="Glob Flag" context="#pop!GlobQualifier" char="q"/>
      </context>

      <!-- GlobModifier is called after a : is encountered in a GlobQualifier -->
      <context attribute="Parameter Expansion" lineEndContext="#pop" name="GlobModifier">
        <DetectChar attribute="Parameter Expansion Operator" context="#stay" char=":"/>
        <AnyChar attribute="Parameter Expansion" context="VarBraceModifier_h" String="ht"/>
        <DetectChar attribute="Parameter Expansion" context="GlobModifier_s" char="s"/>
        <Detect2Chars attribute="Parameter Expansion" context="GlobModifier_s" char="g" char1="s"/>
        <DetectChar attribute="Glob Flag" context="#pop" char=")"/>
      </context>
      <context attribute="Parameter Expansion" lineEndContext="#stay" name="GlobModifier_s" fallthroughContext="#pop">
        <DetectChar attribute="Error" context="#pop#pop" char=")"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!GlobModifier_s_PatPrefix" char="/"/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="GlobModifier_s_PatPrefix" fallthroughContext="#pop!GlobModifier_s_Pat">
        <Detect2Chars attribute="Parameter Expansion Operator" context="#pop!GlobModifier_s_Pat" char="#" char1="%"/>
        <AnyChar attribute="Parameter Expansion Operator" context="#pop!GlobModifier_s_Pat" String="#%"/>
      </context>
      <context attribute="Pattern" lineEndContext="#stay" name="GlobModifier_s_Pat">
        <DetectChar attribute="Parameter Expansion Operator" context="#pop!GlobModifier_s_Rep" char="/"/>
        <IncludeRules context="FindWord"/>
        <IncludeRules context="FindSubPattern"/>
        <DetectChar attribute="Error" context="#pop#pop" char=")"/>
        <DetectIdentifier attribute="Pattern"/>
      </context>
      <context attribute="String DoubleQ" lineEndContext="#stay" name="GlobModifier_s_Rep">
        <DetectChar attribute="Glob Flag" context="#pop#pop" char=")"/>
        <DetectChar attribute="Parameter Expansion Operator" context="#pop" char="/"/>
        <DetectChar attribute="String DoubleQ" context="GlobModifier_s_RecursiveRep" char="("/>
        <IncludeRules context="FindWord"/>
        <DetectIdentifier attribute="String DoubleQ"/>
      </context>
      <context attribute="String DoubleQ" lineEndContext="#stay" name="GlobModifier_s_RecursiveRep">
        <DetectChar attribute="String DoubleQ" context="#pop" char=")"/>
        <DetectChar attribute="String DoubleQ" context="GlobModifier_s_RecursiveRep" char="("/>
        <IncludeRules context="FindWord"/>
        <DetectIdentifier attribute="String DoubleQ"/>
      </context>

    </contexts>

    <itemDatas>
      <itemData name="Normal Text"    defStyleNum="dsNormal"/>
      <itemData name="Comment"        defStyleNum="dsComment"/>
      <itemData name="Keyword"        defStyleNum="dsKeyword"/>
      <itemData name="Control"        defStyleNum="dsKeyword"/>
      <itemData name="Control Flow"   defStyleNum="dsControlFlow"/>
      <itemData name="Builtin"        defStyleNum="dsBuiltIn"/>
      <itemData name="Command"        defStyleNum="dsFunction"/>
      <itemData name="OtherCommand"   defStyleNum="dsExtension"/>
      <itemData name="Redirection"    defStyleNum="dsOperator"/>
      <itemData name="Escape"         defStyleNum="dsDataType"/>
      <itemData name="String SingleQ" defStyleNum="dsString"/>
      <itemData name="String DoubleQ" defStyleNum="dsString"/>
      <itemData name="Here Doc"       defStyleNum="dsString"/>
      <itemData name="Backquote"      defStyleNum="dsKeyword"/>
      <itemData name="String Transl." defStyleNum="dsString"/>
      <itemData name="String Escape"  defStyleNum="dsDataType"/>
      <itemData name="Variable"       defStyleNum="dsVariable"/>
      <itemData name="Expression"     defStyleNum="dsOthers"/>
      <itemData name="Function"       defStyleNum="dsFunction"/>
      <itemData name="Pattern"        defStyleNum="dsSpecialString"/>
      <itemData name="Path"           defStyleNum="dsNormal"/>
      <itemData name="Glob"           defStyleNum="dsPreprocessor"/>
      <itemData name="Glob Flag"      defStyleNum="dsOperator"/>
      <itemData name="Option"         defStyleNum="dsAttribute"/>
      <itemData name="Hex"            defStyleNum="dsBaseN"/>
      <itemData name="Number"         defStyleNum="dsDecVal"/>
      <itemData name="Base"           defStyleNum="dsDataType"/>
      <itemData name="BaseN"          defStyleNum="dsBaseN"/>
      <itemData name="File Descriptor" defStyleNum="dsDecVal"/>
      <itemData name="Parameter Expansion" defStyleNum="dsVariable"/>
      <itemData name="Parameter Expansion Operator" defStyleNum="dsOperator"/>
      <itemData name="Operator"       defStyleNum="dsOperator"/>
      <itemData name="Error"          defStyleNum="dsError"/>
    </itemDatas>
  </highlighting>
  <general>
    <comments>
      <comment name="singleLine" start="#"/>
    </comments>
    <keywords casesensitive="1" weakDeliminator="^%#[]$._:-/" additionalDeliminator="`"/>
  </general>
</language>
<!-- kate: replace-tabs on; indent-width 2; -->
