Warning, /frameworks/syntax-highlighting/data/syntax/fish.xml is written in an unsupported language. File is not indexed.

0001 <?xml version="1.0" encoding="UTF-8"?>
0002 <!DOCTYPE language
0003 [
0004         <!ENTITY tab               "&#x9;">
0005         <!ENTITY white             "&tab; ">                            <!-- first is tab -->
0006         <!ENTITY eocommand         "&white;&lt;&gt;^">                 <!-- end of command separator -->
0007         <!ENTITY separator         "&white;|&amp;;&lt;&gt;()'&quot;">  <!-- token separator as char list -->
0008         <!ENTITY commandsep        "|&amp;;">                          <!-- command separator as char list -->
0009         <!ENTITY special           "{}*/.?\\$&amp;">                   <!-- not allowed in function names -->
0010         <!ENTITY portable_filename "A-Za-z0-9\._-">
0011         <!ENTITY funcname_first    "a-zA-Z+:=!.@_`">
0012         <!ENTITY funcname_last     "a-zA-Z0-9+,-:=!.@#&#37;^_`~">
0013         <!ENTITY funcname          "[&funcname_first;](?:[&funcname_last;]|\\ )*">
0014         <!ENTITY varname           "[A-Za-z0-9_]+">
0015         <!ENTITY alnumdash         "[A-Za-z0-9-]">                     <!-- option chars, dashes for GNU long opts -->
0016         <!ENTITY testoptsfile      "[bcdefgGkLOprsStuwx]">             <!-- test operators for file testing -->
0017         <!ENTITY testoptsother     "[nzao]">                           <!-- other test operators -->
0018         <!ENTITY braceelement      "[!#&#37;+\-\./0-9:=@A-Z^_`a-z~]">
0019         <!ENTITY escapechars       "[abefnrtv $\\*?~&#37;#(){}[\]&lt;&gt;\^&amp;;&quot;&apos;]">   <!-- escape chars -->
0020         <!ENTITY white_or_eol      "(?:[&white;]|$)">
0021         <!ENTITY homedir           "~[&portable_filename;]*">
0022         <!ENTITY pathdetect        "(?:(?:\.\.?|&homedir;)&white_or_eol;|(?:[^$\\{}&separator;/\*\?]|\\&escapechars;)*(:?[/?]|\*\*?))">
0023         <!ENTITY pathpart          "(?:[^&separator;/]|\\&escapechars;)*(?:/|(?=[&quot;']))">
0024 ]>
0025 
0026 
0027 <language name="Fish" version="8" kateversion="5.72" section="Scripts" extensions="*.fish;fishd.*" mimetype="application/x-fish" casesensitive="1" author="Arnd Diestelhorst (adiestelhorst@m-xchg.de)" license="LGPL">
0028 
0029 
0030   <highlighting>
0031 
0032     <list name= "commands">
0033       <item>abbr</item>
0034       <item>alias</item>
0035       <item>argparse</item>
0036       <item>bg</item>
0037       <item>bind</item>
0038       <item>block</item>
0039       <item>cd</item>
0040       <item>cdh</item>
0041       <item>commandline</item>
0042       <item>complete</item>
0043       <item>contains</item>
0044       <item>count</item>
0045       <item>dirs</item>
0046       <item>disown</item>
0047       <item>echo</item>
0048       <item>emit</item>
0049       <item>end</item>
0050       <item>exit</item>
0051       <item>fg</item>
0052       <item>fish</item>
0053       <item>fish_config</item>
0054       <item>fish_indent</item>
0055       <item>fish_key_reader</item>
0056       <item>fish_mode_prompt</item>
0057       <item>fish_opt</item>
0058       <item>fish_prompt</item>
0059       <item>fish_right_prompt</item>
0060       <item>fish_update_completions</item>
0061       <item>fish_vi_mode</item>
0062       <item>funced</item>
0063       <item>funcsave</item>
0064       <item>functions</item>
0065       <item>help</item>
0066       <item>history</item>
0067       <item>isatty</item>
0068       <item>jobs</item>
0069       <item>math</item>
0070       <item>nextd</item>
0071       <item>open</item>
0072       <item>prevd</item>
0073       <item>printf</item>
0074       <item>psub</item>
0075       <item>pushd</item>
0076       <item>random</item>
0077       <item>realpath</item>
0078       <item>return</item>
0079       <item>set_color</item>
0080       <item>source</item>
0081       <item>status</item>
0082       <item>suspend</item>
0083       <item>trap</item>
0084       <item>type</item>
0085       <item>ulimit</item>
0086       <item>umask</item>
0087       <item>vared</item>
0088     </list>
0089 
0090     <list name="commandsnoargs">
0091       <item>break</item>
0092       <item>breakpoint</item>
0093       <item>continue</item>
0094       <item>dirh</item>
0095       <item>false</item> 
0096       <item>popd</item>
0097       <item>prompt_pwd</item>
0098       <item>pwd</item>
0099       <item>true</item>
0100     </list>
0101 
0102     <list name="commandsstay">
0103       <item>and</item>
0104       <item>not</item>
0105       <item>or</item>
0106     </list>
0107 
0108     <list name="stringsubcommands">
0109       <item>escape</item>
0110       <item>join</item>
0111       <item>length</item>
0112       <item>lower</item>
0113       <item>match</item>
0114       <item>repeat</item>
0115       <item>replace</item>
0116       <item>split</item>
0117       <item>sub</item>
0118       <item>trim</item>
0119       <item>unescape</item>
0120       <item>upper</item>
0121     </list>
0122 
0123     <list name="unixcommands">
0124       <include>unixcommands##Bash</include>
0125       <item>command</item>
0126       <item>kill</item>
0127       <item>test</item>
0128     </list>
0129 
0130 
0131 
0132     <contexts>
0133       <context name="Start" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="Root">
0134         <DetectChar attribute="Error" context="DropRestOfLine" char=")"/>
0135       </context>
0136 
0137       <context name="DropRestOfLine" attribute="Normal Text" lineEndContext="#pop">
0138         <DetectChar attribute="Comment" context="Comment" char="#"/>
0139         <RegExpr attribute="Normal Text" String="[^#]*" />
0140       </context>
0141 
0142       <!-- Root starts at a new line (not continuation) -->
0143       <context name="Root" attribute="Normal Text" lineEndContext="#pop">
0144         <LineContinue attribute="Escape" />
0145         <DetectChar attribute="Comment" context="Comment" char="#"/>
0146         <DetectChar context="#pop" char=")" lookAhead="true" />
0147         <IncludeRules context="FindCommands" />
0148       </context>
0149 
0150       <!--
0151       fish interprets closing parenthesis inside comments as end of command substitution, if the comment starts
0152       inside of a command substitution!
0153 
0154       fish does not interpret them this way, when
0155         they are escaped by a \ or
0156         they are matched by an earlier opening parenthesis inside the same comment.
0157       This behaviour is replicated here.
0158 
0159       Command substitutions may span several lines, so the closing parenthesis may be on a different line,
0160       than the opening one. In the interactive shell you need a continuation line for this, not so in scripts.
0161       Blocks of code with multiline command substitutions may be commented out. This should not lead to visual artifacts.
0162 
0163       There is one case, where the following solution fails: a lonely closing ")", which is marked as an error.
0164       -->
0165       <context name="Comment" attribute="Comment" lineEndContext="#pop">
0166         <Detect2Chars attribute="Comment" char="\" char1="(" />
0167         <Detect2Chars attribute="Comment" char="\" char1=")" />
0168         <DetectChar context="CommentParenSub" char="(" />
0169         <DetectChar context="#pop" char=")" lookAhead="true" />
0170         <IncludeRules context="##Comments" />
0171       </context>
0172 
0173       <context name="CommentParenSub" attribute="Comment" lineEndContext="BlockComment">
0174         <DetectChar attribute="Comment" context="#pop" char=")" />
0175         <IncludeRules context="Comment" />
0176       </context>
0177 
0178       <context name="BlockComment" attribute="Comment" fallthroughContext="#pop#pop#pop" lineEndContext="#stay">
0179         <DetectChar attribute="Comment" context="#pop" char="#" firstNonSpace="true"/>
0180       </context>
0181 
0182       <!-- FindCommands matches Fish and Unix commands -->
0183       <!--   order is important, factor out common rules did'nt work because of order of rules-->
0184       <context name="FindCommands" attribute="Command" lineEndContext="#stay">
0185         <DetectSpaces attribute="Normal Text" />
0186         <AnyChar attribute="Error" context="#pop!DropRestOfLine" String="(&lt;&gt;"/>
0187         <AnyChar attribute="Separator" String="&commandsep;" />
0188         <keyword attribute="Builtin" context="Arguments" String="commands" /> <!--simple commands first-->
0189         <keyword attribute="Builtin" context="ArgumentsNone" String="commandsnoargs" />
0190         <keyword attribute="Control Flow" String="commandsstay" />
0191         <Detect2Chars attribute="Builtin" context="Arguments" char="." char1=" " />
0192         <RegExpr attribute="CommandPath" context="CommandPart" String="&pathdetect;" />
0193         <IncludeRules context="FindSpecialCommands" /> <!--before unixcommands, because f test, but after path detection-->
0194         <keyword attribute="UnixCommand" context="Arguments" String="unixcommands"/>
0195         <RegExpr attribute="Command" context="CommandPart" String="&funcname;" />
0196         <DetectChar context="CommandPart" char="&quot;" lookAhead="true"/>
0197       </context>
0198 
0199       <context name="CommandPart" attribute="Command" lineEndContext="#pop">
0200         <LineContinue attribute="Escape" />
0201         <AnyChar context="#pop" String=")#" lookAhead="true"/>
0202         <AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
0203         <AnyChar context="#pop!Arguments" String="&eocommand;" lookAhead="true"/>
0204         <RegExpr attribute="CommandPath" String="&pathpart;" />
0205         <keyword attribute="UnixCommand" String="unixcommands"/>
0206         <RegExpr attribute="Command" String="&funcname;" />
0207         <IncludeRules context="FindStrings" />
0208         <RegExpr attribute="Error" String="." />
0209       </context>
0210 
0211       <context name="FindSpecialCommands" attribute="Builtin" lineEndContext="#stay">
0212         <WordDetect attribute="Builtin" String="command" context="command_builtin" />
0213         <WordDetect attribute="Builtin" String="builtin" context="command_builtin" />
0214         <WordDetect attribute="Builtin" String="eval" context="eval_exec" />
0215         <WordDetect attribute="Builtin" String="exec" context="eval_exec" />
0216         <WordDetect attribute="Builtin" String="set" context="set" />
0217         <WordDetect attribute="Builtin" String="string" context="string" />
0218         <WordDetect attribute="Builtin" String="read" context="read_vared" />
0219         <WordDetect attribute="Builtin" String="vared" context="read_vared" />
0220         <WordDetect attribute="Builtin" String="test" context="ArgumentsTest" />
0221         <Detect2Chars attribute="Builtin" char="[" char1="&tab;" context="ArgumentsTestBrack" />
0222         <Detect2Chars attribute="Builtin" char="[" char1=" " context="ArgumentsTestBrack" />
0223         <WordDetect attribute="Control Flow" String="begin" context="begin" beginRegion="begin" />
0224         <WordDetect attribute="Control Flow" String="for" context="for" beginRegion="for" />
0225         <WordDetect attribute="Control Flow" String="function" context="function" beginRegion="function" />
0226         <WordDetect attribute="Control Flow" String="if" context="if" beginRegion="if" />
0227         <WordDetect attribute="Control Flow" String="switch" context="switch" beginRegion="switch" />
0228         <WordDetect attribute="Control Flow" String="while" context="while" beginRegion="while" />
0229       </context>
0230 
0231       <context name="command_builtin" attribute="Normal Text" lineEndContext="#pop">
0232         <LineContinue attribute="Escape" />
0233         <RegExpr attribute="Option" String="-&alnumdash;*" />
0234         <AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
0235         <IncludeRules context="Root" />
0236       </context>
0237 
0238       <context name="eval_exec" attribute="Normal Text" lineEndContext="#pop">
0239         <DetectChar context="#pop" char=")" lookAhead="true"/>
0240         <AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
0241         <IncludeRules context="FindStrings" />
0242         <IncludeRules context="FindVarExpansion" />
0243         <IncludeRules context="FindSubstitutions" />
0244         <IncludeRules context="FindBraceExpansion" />
0245         <IncludeRules context="FindPaths" />
0246         <IncludeRules context="FindEscapes" />
0247         <IncludeRules context="Root" />
0248       </context>
0249 
0250       <context name="set" attribute="Normal Text" lineEndContext="#pop">
0251         <LineContinue attribute="Escape" />
0252         <AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
0253         <RegExpr attribute="Option" String="-&alnumdash;*" />
0254         <RegExpr attribute="Variable" String="&varname;" context="Arguments" />
0255         <IncludeRules context="FindVarExpansion" />
0256       </context>
0257 
0258       <context name="string" attribute="Normal Text" lineEndContext="#pop">
0259         <LineContinue attribute="Escape" />
0260         <DetectSpaces attribute="Normal Text" />
0261         <keyword attribute="Builtin" context="#pop!Arguments" String="stringsubcommands" />
0262         <RegExpr attribute="Error" String="." />
0263       </context>
0264 
0265       <context name="read_vared" attribute="Normal Text" lineEndContext="#pop">
0266         <LineContinue attribute="Escape" />
0267         <RegExpr attribute="Option" String="-&alnumdash;*" />
0268         <DetectChar attribute="Comment" context="Comment" char="#"/>
0269         <AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
0270         <DetectChar context="#pop" char=")" lookAhead="true"/>
0271         <IncludeRules context="FindStrings" />
0272         <IncludeRules context="FindVarExpansion" />
0273         <IncludeRules context="FindSubstitutions" />
0274         <IncludeRules context="FindBraceExpansion" />
0275         <IncludeRules context="FindEscapes" />
0276         <RegExpr attribute="Variable" String="&varname;" />
0277       </context>
0278 
0279       <context name="ArgumentsTestBrack" attribute="Normal Text" lineEndContext="#pop">
0280         <LineContinue attribute="Escape" />
0281         <Detect2Chars attribute="Builtin" char=" " char1="]" context="#pop!ArgumentsNonePre" />
0282         <AnyChar attribute="Error" context="#pop!DropRestOfLine" String="#&commandsep;&amp;"/>
0283         <IncludeRules context="ArgumentsTest" />
0284       </context>
0285 
0286       <context name="ArgumentsTest" attribute="Normal Text" lineEndContext="#pop">
0287         <LineContinue attribute="Escape" />
0288         <DetectChar context="#pop" char="#" lookAhead="true" />
0289         <IncludeRules context="ArgumentsTest_common" />
0290       </context>
0291 
0292       <context name="ArgumentsTest_common" attribute="Normal Text" lineEndContext="#pop">
0293         <RegExpr attribute="Operator" context="DirectPath" String="-&testoptsfile; " />
0294         <RegExpr attribute="Operator" String="-&testoptsother; |!=?|=| -eq | -ne | -gt | -ge | -lt | -le "/>
0295         <AnyChar context="#pop" String="&commandsep;" lookAhead="true"/>
0296         <IncludeRules context="FindArgumentsCommon" />
0297       </context>
0298 
0299       <context name="begin" attribute="Normal Text" lineEndContext="beginbody">
0300         <DetectSpaces attribute="Normal Text" />
0301         <DetectChar attribute="Separator" context="beginbody" char=";" />
0302         <IncludeRules context="Root" />
0303       </context>
0304 
0305       <context name="beginbody" attribute="Normal Text" lineEndContext="#stay">
0306         <LineContinue attribute="Escape" />
0307         <WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="begin" />
0308         <IncludeRules context="Root" />
0309       </context>
0310 
0311       <context name="for" attribute="Normal Text" lineEndContext="#stay">
0312         <LineContinue attribute="Escape" />
0313         <DetectSpaces attribute="Normal Text" />
0314         <WordDetect attribute="Control Flow" String="in" context="forargs" />
0315         <RegExpr attribute="Variable" String="&varname;" />
0316         <IncludeRules context="FindVarExpansion" />
0317         <RegExpr attribute="Error" String="."/>
0318       </context>
0319 
0320       <context name="forargs" attribute="Normal Text" lineEndContext="forbody">
0321         <DetectChar attribute="Separator" context="forbody" char=";" />
0322         <DetectChar attribute="Comment" context="Comment" char="#"/>
0323         <IncludeRules context="FindArgumentsCommon" />
0324       </context>
0325 
0326       <context name="forbody" attribute="Normal Text" lineEndContext="#stay">
0327         <LineContinue attribute="Escape" />
0328         <WordDetect attribute="Control Flow" String="end" context="#pop#pop#pop" endRegion="for" />
0329         <IncludeRules context="Root" />
0330       </context>
0331 
0332       <context name="function" attribute="Normal Text" lineEndContext="funcbody">
0333         <LineContinue attribute="Escape" />
0334         <DetectSpaces attribute="Normal Text" />
0335         <DetectChar attribute="Comment" context="func_comment" char="#"/>
0336         <DetectChar context="funcopts" char="-" lookAhead="true" />
0337         <DetectChar attribute="Separator" context="funcbody" char=";" />
0338         <RegExpr attribute="Command" String="&funcname;" />
0339         <IncludeRules context="FindVarExpansion" />
0340         <RegExpr attribute="Error" String="."/>
0341       </context>
0342 
0343       <context name="func_comment" attribute="Comment" lineEndContext="#pop!funcbody">
0344       </context>
0345 
0346       <context name="funcopts" attribute="Normal Text" lineEndContext="#pop!funcbody">
0347         <DetectChar attribute="Comment" context="#pop!func_comment" char="#"/>
0348         <RegExpr attribute="Option" String="(?:-d[&white;]*|--description=)(?=[&quot;'])" context="funcdesc" beginRegion="doc"/>
0349         <RegExpr attribute="Option" String="-&alnumdash;*" />
0350         <DetectChar attribute="Separator" context="#pop!funcbody" char=";" />
0351         <IncludeRules context="FindArgumentsCommon" />
0352       </context>
0353 
0354       <context name="funcdesc" attribute="Function Doc" lineEndContext="#stay">
0355         <DetectChar context="DocstringSQ" char="'" />
0356         <DetectChar context="DocstringDQ" char="&quot;" />
0357       </context>
0358 
0359       <!-- StringSQ consumes anything till ' -->
0360       <context name="DocstringSQ" attribute="Function Doc" lineEndContext="#stay">
0361         <!--no line continuation here-->
0362         <Detect2Chars attribute="Escape" char="\" char1="'" />
0363         <Detect2Chars attribute="Escape" char="\" char1="\" />
0364         <DetectChar attribute="Function Doc" context="#pop#pop" char="'" endRegion="doc"/>
0365       </context>
0366 
0367       <!-- StringDQ consumes anything till ", substitutes vars and expressions -->
0368       <context name="DocstringDQ" attribute="Function Doc" lineEndContext="#stay">
0369         <LineContinue attribute="Escape" />
0370         <Detect2Chars attribute="Escape" char="\" char1="&quot;" />
0371         <Detect2Chars attribute="Escape" char="\" char1="$" />
0372         <Detect2Chars attribute="Escape" char="\" char1="\" />
0373         <IncludeRules context="FindVarExpansion" />
0374         <DetectChar attribute="Function Doc" context="#pop#pop" char="&quot;" endRegion="doc"/>
0375       </context>
0376 
0377       <context name="funcbody" attribute="Normal Text" lineEndContext="#stay">
0378         <LineContinue attribute="Escape" />
0379         <WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="function" />
0380         <IncludeRules context="Root" />
0381       </context>
0382 
0383       <context name="if" attribute="Normal Text" lineEndContext="#stay">
0384         <LineContinue attribute="Escape"/>
0385         <WordDetect attribute="Control Flow" String="else" context="else" endRegion="if" beginRegion="if"/>
0386         <WordDetect attribute="Control Flow" String="end" context="#pop" endRegion="if"/>
0387         <IncludeRules context="Root" />
0388       </context>
0389 
0390       <context name="else" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop">
0391         <DetectSpaces attribute="Normal Text" context="#stay"/>
0392         <LineContinue attribute="Escape" context="#stay"/>
0393         <WordDetect attribute="Control Flow" String="if" context="#pop"/>
0394       </context>
0395 
0396       <context name="switch" attribute="Normal Text" lineEndContext="switchbody">
0397         <DetectChar attribute="Separator" context="switchbody" char=";" />
0398         <DetectChar attribute="Comment" context="Comment" char="#"/>
0399         <IncludeRules context="FindArgumentsCommon" />
0400       </context>
0401 
0402       <context name="switchbody" attribute="Normal Text" lineEndContext="#stay">
0403         <LineContinue attribute="Escape" />
0404         <WordDetect attribute="Control Flow" String="case" context="case" beginRegion="case" />
0405         <WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="switch"/>
0406         <IncludeRules context="Root" />
0407       </context>
0408 
0409       <context name="case" attribute="Normal Text" lineEndContext="casebody">
0410         <DetectChar attribute="Separator" context="casebody" char=";" />
0411         <DetectChar attribute="Comment" context="Comment" char="#"/>
0412         <IncludeRules context="FindArgumentsCommon" />
0413       </context>
0414 
0415       <context name="casebody" attribute="Normal Text" lineEndContext="#stay">
0416         <LineContinue attribute="Escape" />
0417         <WordDetect attribute="Control Flow" String="case" context="#pop" endRegion="case" beginRegion="case" />
0418         <WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="case" lookAhead="1"/>
0419         <IncludeRules context="Root" />
0420       </context>
0421 
0422       <context name="while" attribute="Normal Text" lineEndContext="#stay">
0423         <LineContinue attribute="Escape" />
0424         <WordDetect attribute="Control Flow" String="end" context="#pop" endRegion="while"/>
0425         <IncludeRules context="Root" />
0426       </context>
0427 
0428       <!--Argument Rules match the items after a command
0429             this one is a collection with the common part for inclusion-->
0430       <context name="Arguments" attribute="Normal Text" lineEndContext="#pop">
0431         <DetectChar attribute="Comment" context="Comment" char="#"/>
0432         <AnyChar context="#pop" String="&commandsep;)" lookAhead="true"/>
0433         <IncludeRules context="FindArgumentsCommon" />
0434       </context>
0435 
0436       <context name="FindArgumentsCommon" attribute="Normal Text" lineEndContext="#stay">
0437         <LineContinue attribute="Escape" />
0438         <DetectSpaces attribute="Normal Text" />
0439         <RegExpr attribute="Option" String="-&alnumdash;*" />
0440         <RegExpr attribute="Redirection" context="Redirect" String="[0-9]*(?:&gt;{1,2}|&lt;|\^{1,2})" />
0441         <DetectChar attribute="Operator" char="="/>
0442         <DetectChar attribute="Index" context="Subscript" char="["/>
0443         <IncludeRules context="FindStrings" />
0444         <IncludeRules context="FindVarExpansion" />
0445         <IncludeRules context="FindSubstitutions" />
0446         <IncludeRules context="FindBraceExpansion" />
0447         <IncludeRules context="FindProcessExpansion" />
0448         <IncludeRules context="FindPaths" />
0449         <IncludeRules context="FindEscapes" />
0450         <RegExpr attribute="Normal Text" String="[^&separator;&special;]*" />  <!--unknown token-->
0451       </context>
0452 
0453       <context name="ArgumentsNonePre" attribute="Normal Text" lineEndContext="#pop">
0454         <LineContinue attribute="Escape" />
0455         <DetectSpaces attribute="Normal Text" context="#pop!ArgumentsNone" />
0456         <AnyChar context="#pop" String="&commandsep;" lookAhead="true"/> <!--consumed on the "Find"-Level-->
0457         <RegExpr attribute="Error" String="."/>
0458       </context>
0459 
0460       <context name="ArgumentsNone" attribute="Normal Text" lineEndContext="#pop">
0461         <LineContinue attribute="Escape" />
0462         <DetectSpaces attribute="Normal Text" />
0463         <DetectChar attribute="Comment" context="Comment" char="#"/>
0464         <RegExpr attribute="Redirection" context="Redirect" String="[0-9]*(?:&gt;{1,2}|&lt;|\^{1,2})" />
0465         <AnyChar context="#pop" String="&commandsep;)" lookAhead="true"/> <!--consumed on the "Find"-Level-->
0466         <RegExpr attribute="Error" String="[^&commandsep;#]*"/>
0467       </context>
0468 
0469       <context name="TokEnd" attribute="Normal Text" lineEndContext="#pop">
0470         <LineContinue attribute="Escape" />
0471         <DetectSpaces attribute="Normal Text" context="#pop"/>
0472         <AnyChar context="#pop" String="&commandsep;" lookAhead="true"/> <!--consumed on the "Find"-Level-->
0473         <RegExpr attribute="Error" String="." context="#pop"/>
0474       </context>
0475 
0476       <context name="Redirect" attribute="Redirection" fallthroughContext="#pop!DirectPath" lineEndContext="#stay">
0477         <LineContinue attribute="Escape" />
0478         <DetectChar attribute="Redirection" context="#pop!DirectPath" char="?"/>
0479         <DetectChar attribute="Redirection" context="#pop#pop" char="|"/>
0480         <RegExpr    attribute="Redirection" context="#pop!TokEnd" String="&amp;(?:[0-9]+|-)" />
0481       </context>
0482 
0483       <context name="Subscript" attribute="Index" lineEndContext="#pop">
0484         <LineContinue attribute="Escape" />
0485         <Detect2Chars char="]" char1="[" />
0486         <DetectChar attribute="Index" context="#pop" char="]" />
0487         <Detect2Chars char="." char1="." />
0488         <RegExpr attribute="Index" String=" *-?\d+" />
0489         <IncludeRules context="FindVarExpansion" />
0490         <IncludeRules context="FindSubstitutions" />
0491         <DetectSpaces attribute="Normal Text" />
0492         <RegExpr attribute="Error" String="[^\]]" />
0493       </context>
0494 
0495       <!-- FindStrings looks for single and double quoted strings -->
0496       <context name="FindStrings" attribute="Normal Text" lineEndContext="#stay">
0497         <DetectChar context="StringSQ" char="'" />
0498         <DetectChar context="StringDQ" char="&quot;" />
0499       </context>
0500 
0501       <!-- StringSQ consumes anything till ' -->
0502       <context name="StringSQ" attribute="String SingleQ" lineEndContext="#stay">
0503         <!--no line continuation here-->
0504         <Detect2Chars attribute="Escape" char="\" char1="'" />
0505         <Detect2Chars attribute="Escape" char="\" char1="\" />
0506         <DetectChar attribute="String SingleQ" context="#pop" char="'" />
0507       </context>
0508 
0509       <!-- StringDQ consumes anything till ", substitutes vars and expressions -->
0510       <context name="StringDQ" attribute="String DoubleQ" lineEndContext="#stay">
0511         <LineContinue attribute="Escape" />
0512         <Detect2Chars attribute="Escape" char="\" char1="&quot;" />
0513         <Detect2Chars attribute="Escape" char="\" char1="$" />
0514         <Detect2Chars attribute="Escape" char="\" char1="\" />
0515         <IncludeRules context="FindVarExpansion" />
0516         <DetectChar attribute="String DoubleQ" context="#pop" char="&quot;" />
0517       </context>
0518 
0519       <!-- FindVarExpansion goes after anything starting with $ and and their escapes -->
0520       <context name="FindVarExpansion" attribute="Normal Text" lineEndContext="#stay">
0521         <RegExpr attribute="Variable" context="CheckSubscript" String="\$+&varname;" />
0522       </context>
0523 
0524       <!-- Subscript consumes anything till ], marks as Variable -->
0525       <context name="CheckSubscript" attribute="Index" lineEndContext="#pop" fallthroughContext="#pop">
0526         <LineContinue attribute="Escape" />
0527         <DetectChar attribute="Index" context="Subscript" char="["/>
0528       </context>
0529 
0530       <!-- Command Substitution -->
0531       <context name="FindSubstitutions" attribute="Normal Text" lineEndContext="#stay">
0532         <DetectChar attribute="Keychar" context="CommandSubstitution" char="(" />
0533       </context>
0534 
0535       <context name="CommandSubstitution" attribute="Normal Text" fallthroughContext="Root" lineEndContext="#stay">
0536         <LineContinue attribute="Escape" />
0537         <DetectChar attribute="Keychar" context="#pop" char=")" />
0538       </context>
0539 
0540       <!--      Brace Expansion consumes anything till } -->
0541       <context name="FindBraceExpansion" attribute="Normal Text" lineEndContext="#stay">
0542         <DetectChar attribute="Keychar" context="BraceList" char="{" />
0543         <DetectChar attribute="Error" char="}" />
0544       </context>
0545 
0546       <context name="BraceList" attribute="Normal Text" lineEndContext="#pop">
0547         <LineContinue attribute="Escape" />
0548         <DetectChar attribute="Keychar" context="#pop" char="}" />
0549         <DetectChar attribute="Separator" char="," />
0550         <RegExpr attribute="Normal Text" String="&braceelement;*"/>
0551         <IncludeRules context="FindStrings" />
0552         <IncludeRules context="FindVarExpansion" />
0553         <IncludeRules context="FindSubstitutions" />
0554         <IncludeRules context="FindBraceExpansion" />
0555         <IncludeRules context="FindPaths" />
0556         <IncludeRules context="FindEscapes" />
0557         <RegExpr attribute="Error" String="."/>
0558       </context>
0559 
0560       <!--      Process Expansion -->
0561       <context name="FindProcessExpansion" attribute="Normal Text" lineEndContext="#pop">
0562         <DetectChar attribute="Keychar" context="ProcessArg" char="%" />
0563       </context>
0564 
0565       <context name="ProcessArg" attribute="Process" lineEndContext="#pop">
0566         <LineContinue attribute="Escape" />
0567         <AnyChar context="#pop" String="&white;" />
0568         <AnyChar context="#pop" String="&separator;" lookAhead="true" />
0569         <DetectChar attribute="Comment" context="Comment" char="#"/>
0570         <IncludeRules context="FindStrings" />
0571         <IncludeRules context="FindVarExpansion" />
0572         <IncludeRules context="FindSubstitutions" />
0573         <IncludeRules context="FindBraceExpansion" />
0574         <IncludeRules context="FindEscapes" />
0575       </context>
0576 
0577       <!-- FindPaths for parts which might be a path. Uses the matching of a / as heuristic -->
0578       <!-- Might be fooled with quotes -->
0579       <context name="FindPaths" attribute="Path" lineEndContext="#stay">
0580         <RegExpr context="DirectPath" String="&pathdetect;" lookAhead="true" minimal="1"/>
0581       </context>
0582 
0583       <!-- DirectPath is used at places where the next part is definitely a path -->
0584       <context name="DirectPath" attribute="Path" lineEndContext="#pop" fallthroughContext="#pop!PathHead" >
0585         <LineContinue attribute="Escape" />
0586         <DetectSpaces attribute="Normal Text" />
0587         <AnyChar attribute="Error" context="#pop" String="#&commandsep;&lt;&gt;^" />
0588       </context>
0589 
0590       <context name="PathHead" attribute="Path" lineEndContext="#pop" fallthroughContext="#pop!Path" >
0591         <LineContinue attribute="Escape" />
0592         <RegExpr attribute="HomeDir" context="#pop!Path" String="&homedir;" />
0593       </context>
0594 
0595       <context name="Path" attribute="Path" lineEndContext="#pop">
0596         <LineContinue attribute="Escape" />
0597         <DetectSpaces context="#pop" lookAhead="true" />
0598         <AnyChar context="#pop" String="#&commandsep;&lt;&gt;^)" lookAhead="true" />
0599         <AnyChar attribute="Glob" String="*?" />
0600         <DetectChar attribute="Path" char="/" />
0601         <DetectChar attribute="Keychar" context="PathBrace" char="{" />
0602         <DetectChar attribute="Error" context="#pop" char="}" />
0603         <IncludeRules context="FindStrings" />
0604         <IncludeRules context="FindVarExpansion" />
0605         <IncludeRules context="FindSubstitutions" />
0606         <IncludeRules context="FindEscapes" />
0607         <RegExpr attribute="Path" String="[^$\*\?\\{}&separator;/]*" /> <!--consume everything until next special-->
0608       </context>
0609 
0610       <context name="PathBrace" attribute="Path" lineEndContext="#pop">
0611         <LineContinue attribute="Escape" />
0612         <DetectChar attribute="Keychar" context="#pop" char="}" />
0613         <DetectChar attribute="Separator" char="," />
0614         <AnyChar attribute="Error" String=" #&commandsep;&lt;&gt;^)" />
0615         <AnyChar attribute="Glob" String="*?" />
0616         <DetectChar attribute="Path" char="/" />
0617         <DetectChar attribute="Keychar" context="PathBrace" char="{" />
0618         <IncludeRules context="FindStrings" />
0619         <IncludeRules context="FindVarExpansion" />
0620         <IncludeRules context="FindSubstitutions" />
0621         <IncludeRules context="FindEscapes" />
0622         <RegExpr attribute="Path" String="[^$\*\?\\,{}&separator;/]*" />
0623       </context>
0624 
0625       <!-- FindEscapes contains various rules to mark different shell input -->
0626       <context name="FindEscapes" attribute="Normal Text" lineEndContext="#stay">
0627         <RegExpr attribute="Escape" String="\\(?:&escapechars;|[0-7]{1,3}|[xX][A-Fa-f0-9]{1,2}|u[A-Fa-f0-9]{1,4}|U[A-Fa-f0-9]{1,8}|c.)" />
0628       </context>
0629 
0630     </contexts>
0631 
0632     <itemDatas>
0633       <itemData name="Normal Text"    defStyleNum="dsNormal" />
0634       <itemData name="Path"           defStyleNum="dsNormal" />
0635       <itemData name="Option"         defStyleNum="dsNormal" />
0636       <itemData name="Escape"         defStyleNum="dsKeyword" />
0637       <itemData name="Separator"      defStyleNum="dsKeyword" />
0638       <itemData name="Glob"           defStyleNum="dsKeyword" />
0639       <itemData name="HomeDir"        defStyleNum="dsKeyword" />
0640       <itemData name="Keychar"        defStyleNum="dsSpecialChar" />
0641       <itemData name="Command"        defStyleNum="dsFunction" />
0642       <itemData name="UnixCommand"    defStyleNum="dsFunction" />
0643       <itemData name="CommandPath"    defStyleNum="dsExtension" />
0644       <itemData name="Variable"       defStyleNum="dsVariable" />
0645       <itemData name="Control Flow"   defStyleNum="dsControlFlow" />
0646       <itemData name="Operator"       defStyleNum="dsOperator" />
0647       <itemData name="Redirection"    defStyleNum="dsOperator" />
0648       <itemData name="Builtin"        defStyleNum="dsBuiltIn" />
0649       <itemData name="Index"          defStyleNum="dsAttribute" />
0650 
0651       <itemData name="String SingleQ" defStyleNum="dsString" />
0652       <itemData name="String DoubleQ" defStyleNum="dsString" />
0653       <itemData name="Process"        defStyleNum="dsImport" />
0654 
0655 
0656       <itemData name="Comment"        defStyleNum="dsComment" />
0657       <itemData name="Function Doc"   defStyleNum="dsDocumentation" />
0658 
0659       <itemData name="Error"          defStyleNum="dsError" />
0660     </itemDatas>
0661   </highlighting>
0662   <general>
0663     <!-- no / as weakDeliminator, otherwwise in /usr/bin/ls ls is not recognized as UnixCommand -->
0664       <keywords casesensitive="1" weakDeliminator="\+,-:=!.@#&#37;^_`~"  wordWrapDeliminator="&separator;"/>
0665     <comments>
0666       <comment name="singleLine" start="#"/>
0667     </comments>
0668   </general>
0669 </language>