1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language
[
<!ENTITY tab "	">
<!ENTITY white "&tab; "> <!-- first is tab -->
<!ENTITY eocommand "&white;<>^"> <!-- end of command separator -->
<!ENTITY separator "&white;|&;<>()'""> <!-- token separator as char list -->
<!ENTITY commandsep "|&;"> <!-- command separator as char list -->
<!ENTITY special "{}*/.?\\$&"> <!-- not allowed in function names -->
<!ENTITY portable_filename "A-Za-z0-9\._-">
<!ENTITY funcname_first "a-zA-Z+:=!.@_`">
<!ENTITY funcname_last "a-zA-Z0-9+,-:=!.@#%^_`~">
<!ENTITY funcname "[&funcname_first;](?:[&funcname_last;]|\\ )*">
<!ENTITY varname "[A-Za-z0-9_]+">
<!ENTITY alnumdash "[A-Za-z0-9-]"> <!-- option chars, dashes for GNU long opts -->
<!ENTITY testoptsfile "[bcdefgGkLOprsStuwx]"> <!-- test operators for file testing -->
<!ENTITY testoptsother "[nzao]"> <!-- other test operators -->
<!ENTITY braceelement "[!#%+\-\./0-9:=@A-Z^_`a-z~]">
<!ENTITY escapechars "[abefnrtv $\\*?~%#(){}[\]<>\^&;"']"> <!-- escape chars -->
<!ENTITY white_or_eol "(?:[&white;]|$)">
<!ENTITY homedir "~[&portable_filename;]*">
<!ENTITY pathdetect "(?:(?:\.\.?|&homedir;)&white_or_eol;|(?:[^$\\{}&separator;/\*\?]|\\&escapechars;)*(:?[/?]|\*\*?))">
<!ENTITY pathpart "(?:[^&separator;/]|\\&escapechars;)*(?:/|(?=["']))">
]>
<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">
<highlighting>
<list name= "commands">
<item>abbr</item>
<item>alias</item>
<item>argparse</item>
<item>bg</item>
<item>bind</item>
<item>block</item>
<item>cd</item>
<item>cdh</item>
<item>commandline</item>
<item>complete</item>
<item>contains</item>
<item>count</item>
<item>dirs</item>
<item>disown</item>
<item>echo</item>
<item>emit</item>
<item>end</item>
<item>exit</item>
<item>fg</item>
<item>fish</item>
<item>fish_config</item>
<item>fish_indent</item>
<item>fish_key_reader</item>
<item>fish_mode_prompt</item>
<item>fish_opt</item>
<item>fish_prompt</item>
<item>fish_right_prompt</item>
<item>fish_update_completions</item>
<item>fish_vi_mode</item>
<item>funced</item>
<item>funcsave</item>
<item>functions</item>
<item>help</item>
<item>history</item>
<item>isatty</item>
<item>jobs</item>
<item>math</item>
<item>nextd</item>
<item>open</item>
<item>prevd</item>
<item>printf</item>
<item>psub</item>
<item>pushd</item>
<item>random</item>
<item>realpath</item>
<item>return</item>
<item>set_color</item>
<item>source</item>
<item>status</item>
<item>suspend</item>
<item>trap</item>
<item>type</item>
<item>ulimit</item>
<item>umask</item>
<item>vared</item>
</list>
<list name="commandsnoargs">
<item>break</item>
<item>breakpoint</item>
<item>continue</item>
<item>dirh</item>
<item>false</item>
<item>popd</item>
<item>prompt_pwd</item>
<item>pwd</item>
<item>true</item>
</list>
<list name="commandsstay">
<item>and</item>
<item>not</item>
<item>or</item>
</list>
<list name="stringsubcommands">
<item>escape</item>
<item>join</item>
<item>length</item>
<item>lower</item>
<item>match</item>
<item>repeat</item>
<item>replace</item>
<item>split</item>
<item>sub</item>
<item>trim</item>
<item>unescape</item>
<item>upper</item>
</list>
<list name="unixcommands">
<include>unixcommands##Bash</include>
<item>command</item>
<item>kill</item>
<item>test</item>
</list>
<contexts>
<context name="Start" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="Root">
<DetectChar attribute="Error" context="DropRestOfLine" char=")"/>
</context>
<context name="DropRestOfLine" attribute="Normal Text" lineEndContext="#pop">
<DetectChar attribute="Comment" context="Comment" char="#"/>
<RegExpr attribute="Normal Text" String="[^#]*" />
</context>
<!-- Root starts at a new line (not continuation) -->
<context name="Root" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<DetectChar context="#pop" char=")" lookAhead="true" />
<IncludeRules context="FindCommands" />
</context>
<!--
fish interprets closing parenthesis inside comments as end of command substitution, if the comment starts
inside of a command substitution!
fish does not interpret them this way, when
they are escaped by a \ or
they are matched by an earlier opening parenthesis inside the same comment.
This behaviour is replicated here.
Command substitutions may span several lines, so the closing parenthesis may be on a different line,
than the opening one. In the interactive shell you need a continuation line for this, not so in scripts.
Blocks of code with multiline command substitutions may be commented out. This should not lead to visual artifacts.
There is one case, where the following solution fails: a lonely closing ")", which is marked as an error.
-->
<context name="Comment" attribute="Comment" lineEndContext="#pop">
<Detect2Chars attribute="Comment" char="\" char1="(" />
<Detect2Chars attribute="Comment" char="\" char1=")" />
<DetectChar context="CommentParenSub" char="(" />
<DetectChar context="#pop" char=")" lookAhead="true" />
<IncludeRules context="##Comments" />
</context>
<context name="CommentParenSub" attribute="Comment" lineEndContext="BlockComment">
<DetectChar attribute="Comment" context="#pop" char=")" />
<IncludeRules context="Comment" />
</context>
<context name="BlockComment" attribute="Comment" fallthroughContext="#pop#pop#pop" lineEndContext="#stay">
<DetectChar attribute="Comment" context="#pop" char="#" firstNonSpace="true"/>
</context>
<!-- FindCommands matches Fish and Unix commands -->
<!-- order is important, factor out common rules did'nt work because of order of rules-->
<context name="FindCommands" attribute="Command" lineEndContext="#stay">
<DetectSpaces attribute="Normal Text" />
<AnyChar attribute="Error" context="#pop!DropRestOfLine" String="(<>"/>
<AnyChar attribute="Separator" String="&commandsep;" />
<keyword attribute="Builtin" context="Arguments" String="commands" /> <!--simple commands first-->
<keyword attribute="Builtin" context="ArgumentsNone" String="commandsnoargs" />
<keyword attribute="Control Flow" String="commandsstay" />
<Detect2Chars attribute="Builtin" context="Arguments" char="." char1=" " />
<RegExpr attribute="CommandPath" context="CommandPart" String="&pathdetect;" />
<IncludeRules context="FindSpecialCommands" /> <!--before unixcommands, because f test, but after path detection-->
<keyword attribute="UnixCommand" context="Arguments" String="unixcommands"/>
<RegExpr attribute="Command" context="CommandPart" String="&funcname;" />
<DetectChar context="CommandPart" char=""" lookAhead="true"/>
</context>
<context name="CommandPart" attribute="Command" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<AnyChar context="#pop" String=")#" lookAhead="true"/>
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<AnyChar context="#pop!Arguments" String="&eocommand;" lookAhead="true"/>
<RegExpr attribute="CommandPath" String="&pathpart;" />
<keyword attribute="UnixCommand" String="unixcommands"/>
<RegExpr attribute="Command" String="&funcname;" />
<IncludeRules context="FindStrings" />
<RegExpr attribute="Error" String="." />
</context>
<context name="FindSpecialCommands" attribute="Builtin" lineEndContext="#stay">
<WordDetect attribute="Builtin" String="command" context="command_builtin" />
<WordDetect attribute="Builtin" String="builtin" context="command_builtin" />
<WordDetect attribute="Builtin" String="eval" context="eval_exec" />
<WordDetect attribute="Builtin" String="exec" context="eval_exec" />
<WordDetect attribute="Builtin" String="set" context="set" />
<WordDetect attribute="Builtin" String="string" context="string" />
<WordDetect attribute="Builtin" String="read" context="read_vared" />
<WordDetect attribute="Builtin" String="vared" context="read_vared" />
<WordDetect attribute="Builtin" String="test" context="ArgumentsTest" />
<Detect2Chars attribute="Builtin" char="[" char1="&tab;" context="ArgumentsTestBrack" />
<Detect2Chars attribute="Builtin" char="[" char1=" " context="ArgumentsTestBrack" />
<WordDetect attribute="Control Flow" String="begin" context="begin" beginRegion="begin" />
<WordDetect attribute="Control Flow" String="for" context="for" beginRegion="for" />
<WordDetect attribute="Control Flow" String="function" context="function" beginRegion="function" />
<WordDetect attribute="Control Flow" String="if" context="if" beginRegion="if" />
<WordDetect attribute="Control Flow" String="switch" context="switch" beginRegion="switch" />
<WordDetect attribute="Control Flow" String="while" context="while" beginRegion="while" />
</context>
<context name="command_builtin" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<RegExpr attribute="Option" String="-&alnumdash;*" />
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<IncludeRules context="Root" />
</context>
<context name="eval_exec" attribute="Normal Text" lineEndContext="#pop">
<DetectChar context="#pop" char=")" lookAhead="true"/>
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindPaths" />
<IncludeRules context="FindEscapes" />
<IncludeRules context="Root" />
</context>
<context name="set" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<RegExpr attribute="Option" String="-&alnumdash;*" />
<RegExpr attribute="Variable" String="&varname;" context="Arguments" />
<IncludeRules context="FindVarExpansion" />
</context>
<context name="string" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<keyword attribute="Builtin" context="#pop!Arguments" String="stringsubcommands" />
<RegExpr attribute="Error" String="." />
</context>
<context name="read_vared" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<RegExpr attribute="Option" String="-&alnumdash;*" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<AnyChar attribute="Separator" context="#pop" String="&commandsep;" />
<DetectChar context="#pop" char=")" lookAhead="true"/>
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Variable" String="&varname;" />
</context>
<context name="ArgumentsTestBrack" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<Detect2Chars attribute="Builtin" char=" " char1="]" context="#pop!ArgumentsNonePre" />
<AnyChar attribute="Error" context="#pop!DropRestOfLine" String="#&commandsep;&"/>
<IncludeRules context="ArgumentsTest" />
</context>
<context name="ArgumentsTest" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectChar context="#pop" char="#" lookAhead="true" />
<IncludeRules context="ArgumentsTest_common" />
</context>
<context name="ArgumentsTest_common" attribute="Normal Text" lineEndContext="#pop">
<RegExpr attribute="Operator" context="DirectPath" String="-&testoptsfile; " />
<RegExpr attribute="Operator" String="-&testoptsother; |!=?|=| -eq | -ne | -gt | -ge | -lt | -le "/>
<AnyChar context="#pop" String="&commandsep;" lookAhead="true"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="begin" attribute="Normal Text" lineEndContext="beginbody">
<DetectSpaces attribute="Normal Text" />
<DetectChar attribute="Separator" context="beginbody" char=";" />
<IncludeRules context="Root" />
</context>
<context name="beginbody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="begin" />
<IncludeRules context="Root" />
</context>
<context name="for" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<WordDetect attribute="Control Flow" String="in" context="forargs" />
<RegExpr attribute="Variable" String="&varname;" />
<IncludeRules context="FindVarExpansion" />
<RegExpr attribute="Error" String="."/>
</context>
<context name="forargs" attribute="Normal Text" lineEndContext="forbody">
<DetectChar attribute="Separator" context="forbody" char=";" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="forbody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop#pop" endRegion="for" />
<IncludeRules context="Root" />
</context>
<context name="function" attribute="Normal Text" lineEndContext="funcbody">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<DetectChar attribute="Comment" context="func_comment" char="#"/>
<DetectChar context="funcopts" char="-" lookAhead="true" />
<DetectChar attribute="Separator" context="funcbody" char=";" />
<RegExpr attribute="Command" String="&funcname;" />
<IncludeRules context="FindVarExpansion" />
<RegExpr attribute="Error" String="."/>
</context>
<context name="func_comment" attribute="Comment" lineEndContext="#pop!funcbody">
</context>
<context name="funcopts" attribute="Normal Text" lineEndContext="#pop!funcbody">
<DetectChar attribute="Comment" context="#pop!func_comment" char="#"/>
<RegExpr attribute="Option" String="(?:-d[&white;]*|--description=)(?=["'])" context="funcdesc" beginRegion="doc"/>
<RegExpr attribute="Option" String="-&alnumdash;*" />
<DetectChar attribute="Separator" context="#pop!funcbody" char=";" />
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="funcdesc" attribute="Function Doc" lineEndContext="#stay">
<DetectChar context="DocstringSQ" char="'" />
<DetectChar context="DocstringDQ" char=""" />
</context>
<!-- StringSQ consumes anything till ' -->
<context name="DocstringSQ" attribute="Function Doc" lineEndContext="#stay">
<!--no line continuation here-->
<Detect2Chars attribute="Escape" char="\" char1="'" />
<Detect2Chars attribute="Escape" char="\" char1="\" />
<DetectChar attribute="Function Doc" context="#pop#pop" char="'" endRegion="doc"/>
</context>
<!-- StringDQ consumes anything till ", substitutes vars and expressions -->
<context name="DocstringDQ" attribute="Function Doc" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<Detect2Chars attribute="Escape" char="\" char1=""" />
<Detect2Chars attribute="Escape" char="\" char1="$" />
<Detect2Chars attribute="Escape" char="\" char1="\" />
<IncludeRules context="FindVarExpansion" />
<DetectChar attribute="Function Doc" context="#pop#pop" char=""" endRegion="doc"/>
</context>
<context name="funcbody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="function" />
<IncludeRules context="Root" />
</context>
<context name="if" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape"/>
<WordDetect attribute="Control Flow" String="else" context="else" endRegion="if" beginRegion="if"/>
<WordDetect attribute="Control Flow" String="end" context="#pop" endRegion="if"/>
<IncludeRules context="Root" />
</context>
<context name="else" attribute="Normal Text" lineEndContext="#stay" fallthroughContext="#pop">
<DetectSpaces attribute="Normal Text" context="#stay"/>
<LineContinue attribute="Escape" context="#stay"/>
<WordDetect attribute="Control Flow" String="if" context="#pop"/>
</context>
<context name="switch" attribute="Normal Text" lineEndContext="switchbody">
<DetectChar attribute="Separator" context="switchbody" char=";" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="switchbody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="case" context="case" beginRegion="case" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="switch"/>
<IncludeRules context="Root" />
</context>
<context name="case" attribute="Normal Text" lineEndContext="casebody">
<DetectChar attribute="Separator" context="casebody" char=";" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="casebody" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="case" context="#pop" endRegion="case" beginRegion="case" />
<WordDetect attribute="Control Flow" String="end" context="#pop#pop" endRegion="case" lookAhead="1"/>
<IncludeRules context="Root" />
</context>
<context name="while" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<WordDetect attribute="Control Flow" String="end" context="#pop" endRegion="while"/>
<IncludeRules context="Root" />
</context>
<!--Argument Rules match the items after a command
this one is a collection with the common part for inclusion-->
<context name="Arguments" attribute="Normal Text" lineEndContext="#pop">
<DetectChar attribute="Comment" context="Comment" char="#"/>
<AnyChar context="#pop" String="&commandsep;)" lookAhead="true"/>
<IncludeRules context="FindArgumentsCommon" />
</context>
<context name="FindArgumentsCommon" attribute="Normal Text" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<RegExpr attribute="Option" String="-&alnumdash;*" />
<RegExpr attribute="Redirection" context="Redirect" String="[0-9]*(?:>{1,2}|<|\^{1,2})" />
<DetectChar attribute="Operator" char="="/>
<DetectChar attribute="Index" context="Subscript" char="["/>
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindProcessExpansion" />
<IncludeRules context="FindPaths" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Normal Text" String="[^&separator;&special;]*" /> <!--unknown token-->
</context>
<context name="ArgumentsNonePre" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" context="#pop!ArgumentsNone" />
<AnyChar context="#pop" String="&commandsep;" lookAhead="true"/> <!--consumed on the "Find"-Level-->
<RegExpr attribute="Error" String="."/>
</context>
<context name="ArgumentsNone" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<RegExpr attribute="Redirection" context="Redirect" String="[0-9]*(?:>{1,2}|<|\^{1,2})" />
<AnyChar context="#pop" String="&commandsep;)" lookAhead="true"/> <!--consumed on the "Find"-Level-->
<RegExpr attribute="Error" String="[^&commandsep;#]*"/>
</context>
<context name="TokEnd" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" context="#pop"/>
<AnyChar context="#pop" String="&commandsep;" lookAhead="true"/> <!--consumed on the "Find"-Level-->
<RegExpr attribute="Error" String="." context="#pop"/>
</context>
<context name="Redirect" attribute="Redirection" fallthroughContext="#pop!DirectPath" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<DetectChar attribute="Redirection" context="#pop!DirectPath" char="?"/>
<DetectChar attribute="Redirection" context="#pop#pop" char="|"/>
<RegExpr attribute="Redirection" context="#pop!TokEnd" String="&(?:[0-9]+|-)" />
</context>
<context name="Subscript" attribute="Index" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<Detect2Chars char="]" char1="[" />
<DetectChar attribute="Index" context="#pop" char="]" />
<Detect2Chars char="." char1="." />
<RegExpr attribute="Index" String=" *-?\d+" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<DetectSpaces attribute="Normal Text" />
<RegExpr attribute="Error" String="[^\]]" />
</context>
<!-- FindStrings looks for single and double quoted strings -->
<context name="FindStrings" attribute="Normal Text" lineEndContext="#stay">
<DetectChar context="StringSQ" char="'" />
<DetectChar context="StringDQ" char=""" />
</context>
<!-- StringSQ consumes anything till ' -->
<context name="StringSQ" attribute="String SingleQ" lineEndContext="#stay">
<!--no line continuation here-->
<Detect2Chars attribute="Escape" char="\" char1="'" />
<Detect2Chars attribute="Escape" char="\" char1="\" />
<DetectChar attribute="String SingleQ" context="#pop" char="'" />
</context>
<!-- StringDQ consumes anything till ", substitutes vars and expressions -->
<context name="StringDQ" attribute="String DoubleQ" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<Detect2Chars attribute="Escape" char="\" char1=""" />
<Detect2Chars attribute="Escape" char="\" char1="$" />
<Detect2Chars attribute="Escape" char="\" char1="\" />
<IncludeRules context="FindVarExpansion" />
<DetectChar attribute="String DoubleQ" context="#pop" char=""" />
</context>
<!-- FindVarExpansion goes after anything starting with $ and and their escapes -->
<context name="FindVarExpansion" attribute="Normal Text" lineEndContext="#stay">
<RegExpr attribute="Variable" context="CheckSubscript" String="\$+&varname;" />
</context>
<!-- Subscript consumes anything till ], marks as Variable -->
<context name="CheckSubscript" attribute="Index" lineEndContext="#pop" fallthroughContext="#pop">
<LineContinue attribute="Escape" />
<DetectChar attribute="Index" context="Subscript" char="["/>
</context>
<!-- Command Substitution -->
<context name="FindSubstitutions" attribute="Normal Text" lineEndContext="#stay">
<DetectChar attribute="Keychar" context="CommandSubstitution" char="(" />
</context>
<context name="CommandSubstitution" attribute="Normal Text" fallthroughContext="Root" lineEndContext="#stay">
<LineContinue attribute="Escape" />
<DetectChar attribute="Keychar" context="#pop" char=")" />
</context>
<!-- Brace Expansion consumes anything till } -->
<context name="FindBraceExpansion" attribute="Normal Text" lineEndContext="#stay">
<DetectChar attribute="Keychar" context="BraceList" char="{" />
<DetectChar attribute="Error" char="}" />
</context>
<context name="BraceList" attribute="Normal Text" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectChar attribute="Keychar" context="#pop" char="}" />
<DetectChar attribute="Separator" char="," />
<RegExpr attribute="Normal Text" String="&braceelement;*"/>
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindPaths" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Error" String="."/>
</context>
<!-- Process Expansion -->
<context name="FindProcessExpansion" attribute="Normal Text" lineEndContext="#pop">
<DetectChar attribute="Keychar" context="ProcessArg" char="%" />
</context>
<context name="ProcessArg" attribute="Process" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<AnyChar context="#pop" String="&white;" />
<AnyChar context="#pop" String="&separator;" lookAhead="true" />
<DetectChar attribute="Comment" context="Comment" char="#"/>
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindBraceExpansion" />
<IncludeRules context="FindEscapes" />
</context>
<!-- FindPaths for parts which might be a path. Uses the matching of a / as heuristic -->
<!-- Might be fooled with quotes -->
<context name="FindPaths" attribute="Path" lineEndContext="#stay">
<RegExpr context="DirectPath" String="&pathdetect;" lookAhead="true" minimal="1"/>
</context>
<!-- DirectPath is used at places where the next part is definitely a path -->
<context name="DirectPath" attribute="Path" lineEndContext="#pop" fallthroughContext="#pop!PathHead" >
<LineContinue attribute="Escape" />
<DetectSpaces attribute="Normal Text" />
<AnyChar attribute="Error" context="#pop" String="#&commandsep;<>^" />
</context>
<context name="PathHead" attribute="Path" lineEndContext="#pop" fallthroughContext="#pop!Path" >
<LineContinue attribute="Escape" />
<RegExpr attribute="HomeDir" context="#pop!Path" String="&homedir;" />
</context>
<context name="Path" attribute="Path" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectSpaces context="#pop" lookAhead="true" />
<AnyChar context="#pop" String="#&commandsep;<>^)" lookAhead="true" />
<AnyChar attribute="Glob" String="*?" />
<DetectChar attribute="Path" char="/" />
<DetectChar attribute="Keychar" context="PathBrace" char="{" />
<DetectChar attribute="Error" context="#pop" char="}" />
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Path" String="[^$\*\?\\{}&separator;/]*" /> <!--consume everything until next special-->
</context>
<context name="PathBrace" attribute="Path" lineEndContext="#pop">
<LineContinue attribute="Escape" />
<DetectChar attribute="Keychar" context="#pop" char="}" />
<DetectChar attribute="Separator" char="," />
<AnyChar attribute="Error" String=" #&commandsep;<>^)" />
<AnyChar attribute="Glob" String="*?" />
<DetectChar attribute="Path" char="/" />
<DetectChar attribute="Keychar" context="PathBrace" char="{" />
<IncludeRules context="FindStrings" />
<IncludeRules context="FindVarExpansion" />
<IncludeRules context="FindSubstitutions" />
<IncludeRules context="FindEscapes" />
<RegExpr attribute="Path" String="[^$\*\?\\,{}&separator;/]*" />
</context>
<!-- FindEscapes contains various rules to mark different shell input -->
<context name="FindEscapes" attribute="Normal Text" lineEndContext="#stay">
<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.)" />
</context>
</contexts>
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal" />
<itemData name="Path" defStyleNum="dsNormal" />
<itemData name="Option" defStyleNum="dsNormal" />
<itemData name="Escape" defStyleNum="dsKeyword" />
<itemData name="Separator" defStyleNum="dsKeyword" />
<itemData name="Glob" defStyleNum="dsKeyword" />
<itemData name="HomeDir" defStyleNum="dsKeyword" />
<itemData name="Keychar" defStyleNum="dsSpecialChar" />
<itemData name="Command" defStyleNum="dsFunction" />
<itemData name="UnixCommand" defStyleNum="dsFunction" />
<itemData name="CommandPath" defStyleNum="dsExtension" />
<itemData name="Variable" defStyleNum="dsVariable" />
<itemData name="Control Flow" defStyleNum="dsControlFlow" />
<itemData name="Operator" defStyleNum="dsOperator" />
<itemData name="Redirection" defStyleNum="dsOperator" />
<itemData name="Builtin" defStyleNum="dsBuiltIn" />
<itemData name="Index" defStyleNum="dsAttribute" />
<itemData name="String SingleQ" defStyleNum="dsString" />
<itemData name="String DoubleQ" defStyleNum="dsString" />
<itemData name="Process" defStyleNum="dsImport" />
<itemData name="Comment" defStyleNum="dsComment" />
<itemData name="Function Doc" defStyleNum="dsDocumentation" />
<itemData name="Error" defStyleNum="dsError" />
</itemDatas>
</highlighting>
<general>
<!-- no / as weakDeliminator, otherwwise in /usr/bin/ls ls is not recognized as UnixCommand -->
<keywords casesensitive="1" weakDeliminator="\+,-:=!.@#%^_`~" wordWrapDeliminator="&separator;"/>
<comments>
<comment name="singleLine" start="#"/>
</comments>
</general>
</language>
|