Changeset View
Changeset View
Standalone View
Standalone View
data/syntax/bash.xml
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
|---|---|---|---|---|---|
| 2 | <!DOCTYPE language SYSTEM "language.dtd" | 2 | <!DOCTYPE language SYSTEM "language.dtd" | ||
| 3 | [ | 3 | [ | ||
| 4 | <!ENTITY funcname "[A-Za-z_:][A-Za-z0-9_:#%@-]*"> | 4 | <!ENTITY funcname "[A-Za-z_:][A-Za-z0-9_:#%@-]*"> | ||
| 5 | <!ENTITY varname "[A-Za-z_][A-Za-z0-9_]*"> | 5 | <!ENTITY varname "[A-Za-z_][A-Za-z0-9_]*"> | ||
| 6 | <!ENTITY word "[^|&;()<>\s]+"> <!-- see man bash --> | 6 | <!ENTITY word "[^|&;()<>\s]+"> <!-- see man bash --> | ||
| 7 | <!ENTITY eos "(?=($|\s))"> <!-- eol or space following --> | 7 | <!ENTITY eos "(?=($|\s))"> <!-- eol or space following --> | ||
| 8 | <!ENTITY noword "(?![\w$+-])"> <!-- no word, $, + or - following --> | 8 | <!ENTITY noword "(?![\w$+-])"> <!-- no word, $, + or - following --> | ||
| 9 | <!ENTITY pathpart "([\w_@.%*?+-]|\\ )"> <!-- valid character in a file name --> | 9 | <!ENTITY pathpart "([\w_@.%*?+-]|\\ )"> <!-- valid character in a file name --> | ||
| 10 | <!ENTITY charbeforecomment "[\s;]"> <!-- character before a comment # --> | ||||
| 10 | ]> | 11 | ]> | ||
| 11 | <language name="Bash" version="9" kateversion="5.0" section="Scripts" extensions="*.sh;*.bash;*.ebuild;*.eclass;*.nix;.bashrc;.bash_profile;.bash_login;.profile;PKGBUILD;APKBUILD" mimetype="application/x-shellscript" casesensitive="1" author="Wilbert Berendsen (wilbert@kde.nl)" license="LGPL"> | 12 | <language name="Bash" version="10" kateversion="5.0" section="Scripts" extensions="*.sh;*.bash;*.ebuild;*.eclass;*.nix;.bashrc;.bash_profile;.bash_login;.profile;PKGBUILD;APKBUILD" mimetype="application/x-shellscript" casesensitive="1" author="Wilbert Berendsen (wilbert@kde.nl)" license="LGPL"> | ||
| 12 | 13 | | |||
| 13 | <!-- (c) 2004 by Wilbert Berendsen (wilbert@kde.nl) | 14 | <!-- (c) 2004 by Wilbert Berendsen (wilbert@kde.nl) | ||
| 14 | Changes by Matthew Woehlke (mw_triad@users.sourceforge.net) | 15 | Changes by Matthew Woehlke (mw_triad@users.sourceforge.net) | ||
| 15 | Changes by Sebastian Pipping (webmaster@hartwork.org) | 16 | Changes by Sebastian Pipping (webmaster@hartwork.org) | ||
| 16 | Changes by Luiz Angelo Daros de Luca (luizluca@gmail.com) | 17 | Changes by Luiz Angelo Daros de Luca (luizluca@gmail.com) | ||
| 17 | Released under the LGPL, part of kdelibs/kate --> | 18 | Released under the LGPL, part of kdelibs/kate --> | ||
| 18 | 19 | | |||
| 19 | <highlighting> | 20 | <highlighting> | ||
| ▲ Show 20 Lines • Show All 448 Lines • ▼ Show 20 Line(s) | 466 | <context attribute="Normal Text" lineEndContext="#stay" name="FindAll"> | |||
| 468 | <IncludeRules context="FindStrings" /> | 469 | <IncludeRules context="FindStrings" /> | ||
| 469 | <IncludeRules context="FindSubstitutions" /> | 470 | <IncludeRules context="FindSubstitutions" /> | ||
| 470 | <IncludeRules context="FindOthers" /> | 471 | <IncludeRules context="FindOthers" /> | ||
| 471 | </context> | 472 | </context> | ||
| 472 | 473 | | |||
| 473 | <!-- FindMost tries to interpret anything except commands --> | 474 | <!-- FindMost tries to interpret anything except commands --> | ||
| 474 | <context attribute="Normal Text" lineEndContext="#stay" name="FindMost"> | 475 | <context attribute="Normal Text" lineEndContext="#stay" name="FindMost"> | ||
| 475 | <IncludeRules context="FindComments" /> | 476 | <IncludeRules context="FindComments" /> | ||
| 477 | <IncludeRules context="FindMostWithoutComments" /> | ||||
| 478 | </context> | ||||
| 479 | <context attribute="Normal Text" lineEndContext="#stay" name="FindMostWithoutComments"> | ||||
| 476 | <IncludeRules context="FindStrings" /> | 480 | <IncludeRules context="FindStrings" /> | ||
| 477 | <IncludeRules context="FindSubstitutions" /> | 481 | <IncludeRules context="FindSubstitutions" /> | ||
| 478 | <IncludeRules context="FindOthers" /> | 482 | <IncludeRules context="FindOthers" /> | ||
| 479 | </context> | 483 | </context> | ||
| 480 | 484 | | |||
| 481 | 485 | | |||
| 482 | <!-- FindComments consumes shell comments till EOL --> | 486 | <!-- FindComments consumes shell comments till EOL --> | ||
| 483 | <context attribute="Normal Text" lineEndContext="#pop" name="FindComments"> | 487 | <context attribute="Normal Text" lineEndContext="#pop" name="FindComments"> | ||
| 484 | <DetectChar attribute="Comment" context="Comment" char="#" firstNonSpace="true"/> | 488 | <DetectChar attribute="Comment" context="Comment" char="#" firstNonSpace="true"/> | ||
| 485 | <RegExpr attribute="Normal Text" context="Comment" String="[\s;](?=#)" /> | 489 | <RegExpr attribute="Comment" context="Comment" String="(?<=&charbeforecomment;)#" /> | ||
| 490 | </context> | ||||
| 491 | <context attribute="Normal Text" lineEndContext="#pop" name="FindCommentsInCommand"> | ||||
| 492 | <DetectChar attribute="Comment" context="Comment" char="#" firstNonSpace="true"/> | ||||
| 493 | <!-- NOTE: If a rule already matches a character of &charbeforecomment; | ||||
| 494 | (for example, in an escaped character), the comment will not be highlighted. --> | ||||
| 495 | <RegExpr attribute="Normal Text" context="Comment" String="&charbeforecomment;(?=#)" /> | ||||
| 486 | </context> | 496 | </context> | ||
| 487 | <context attribute="Comment" lineEndContext="#pop" name="Comment"> | 497 | <context attribute="Comment" lineEndContext="#pop" name="Comment"> | ||
| 488 | <IncludeRules context="##Alerts" /> | 498 | <IncludeRules context="##Alerts" /> | ||
| 489 | <IncludeRules context="##Modelines" /> | 499 | <IncludeRules context="##Modelines" /> | ||
| 490 | </context> | 500 | </context> | ||
| 491 | 501 | | |||
| 492 | <!-- FindCommentsParen consumes shell comments till EOL or a closing parenthese --> | 502 | <!-- FindCommentsParen consumes shell comments till EOL or a closing parenthese --> | ||
| 493 | <context attribute="Normal Text" lineEndContext="#pop" name="FindCommentsParen"> | 503 | <context attribute="Normal Text" lineEndContext="#pop" name="FindCommentsParen"> | ||
| 494 | <DetectChar attribute="Comment" context="CommentParen" char="#" firstNonSpace="true"/> | 504 | <DetectChar attribute="Comment" context="CommentParen" char="#" firstNonSpace="true"/> | ||
| 495 | <RegExpr attribute="Normal Text" context="CommentParen" String="[\s;](?=#)" /> | 505 | <RegExpr attribute="Normal Text" context="CommentParen" String="&charbeforecomment;(?=#)" /> | ||
| 496 | </context> | 506 | </context> | ||
| 497 | <context attribute="Comment" lineEndContext="#pop" name="CommentParen"> | 507 | <context attribute="Comment" lineEndContext="#pop" name="CommentParen"> | ||
| 498 | <RegExpr attribute="Comment" context="#pop" String="[^)](?=\))" /> | 508 | <RegExpr attribute="Comment" context="#pop" String="[^)](?=\))" /> | ||
| 499 | <IncludeRules context="##Alerts" /> | 509 | <IncludeRules context="##Alerts" /> | ||
| 500 | </context> | 510 | </context> | ||
| 501 | 511 | | |||
| 502 | <!-- FindCommentsBackq consumes shell comments till EOL or a backquote --> | 512 | <!-- FindCommentsBackq consumes shell comments till EOL or a backquote --> | ||
| 503 | <context attribute="Normal Text" lineEndContext="#pop" name="FindCommentsBackq"> | 513 | <context attribute="Normal Text" lineEndContext="#pop" name="FindCommentsBackq"> | ||
| 504 | <DetectChar attribute="Comment" context="CommentBackq" char="#" firstNonSpace="true"/> | 514 | <DetectChar attribute="Comment" context="CommentBackq" char="#" firstNonSpace="true"/> | ||
| 505 | <RegExpr attribute="Normal Text" context="CommentBackq" String="[\s;](?=#)" /> | 515 | <RegExpr attribute="Normal Text" context="CommentBackq" String="&charbeforecomment;(?=#)" /> | ||
| 506 | </context> | 516 | </context> | ||
| 507 | <context attribute="Comment" lineEndContext="#pop" name="CommentBackq"> | 517 | <context attribute="Comment" lineEndContext="#pop" name="CommentBackq"> | ||
| 508 | <RegExpr attribute="Comment" context="#pop" String="[^`](?=`)" /> | 518 | <RegExpr attribute="Comment" context="#pop" String="[^`](?=`)" /> | ||
| 509 | <IncludeRules context="##Alerts" /> | 519 | <IncludeRules context="##Alerts" /> | ||
| 510 | </context> | 520 | </context> | ||
| 511 | 521 | | |||
| 512 | 522 | | |||
| 513 | <!-- FindCommands matches many items that can be expected outside strings, substitutions etc. --> | 523 | <!-- FindCommands matches many items that can be expected outside strings, substitutions etc. --> | ||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
| 562 | <context attribute="Normal Text" lineEndContext="#stay" name="FindNormalCommands"> | 572 | <context attribute="Normal Text" lineEndContext="#stay" name="FindNormalCommands"> | ||
| 563 | <keyword attribute="Builtin" context="CommandArgs" String="builtins" /> | 573 | <keyword attribute="Builtin" context="CommandArgs" String="builtins" /> | ||
| 564 | <keyword attribute="Command" context="CommandArgs" String="unixcommands" /> | 574 | <keyword attribute="Command" context="CommandArgs" String="unixcommands" /> | ||
| 565 | <RegExpr attribute="OtherCommand" context="#stay" String="&pathpart;*(?=/)" /> | 575 | <RegExpr attribute="OtherCommand" context="#stay" String="&pathpart;*(?=/)" /> | ||
| 566 | <RegExpr attribute="OtherCommand" context="#stay" String="~\w*" /> | 576 | <RegExpr attribute="OtherCommand" context="#stay" String="~\w*" /> | ||
| 567 | <RegExpr attribute="OtherCommand" context="#stay" String="/&pathpart;*(?=([/);$`'"]|$))" /> | 577 | <RegExpr attribute="OtherCommand" context="#stay" String="/&pathpart;*(?=([/);$`'"]|$))" /> | ||
| 568 | <RegExpr attribute="OtherCommand" context="CommandArgs" String="/&pathpart;*(?=([\s);$`'"]|$))" /> | 578 | <RegExpr attribute="OtherCommand" context="CommandArgs" String="/&pathpart;*(?=([\s);$`'"]|$))" /> | ||
| 569 | <!-- This list is not complete. ie, ":" is missing but as it is in bash completition. --> | 579 | <!-- This list is not complete. ie, ":" is missing but as it is in bash completition. --> | ||
| 570 | <RegExpr attribute="OtherCommand" context="CommandArgs" String="&pathpart;*" /> | 580 | <RegExpr attribute="OtherCommand" context="CommandArgsNormal" String="&pathpart;*" /> | ||
| 571 | </context> | 581 | </context> | ||
| 572 | 582 | | |||
| 573 | <!-- CommandArgs matches the items after a command --> | 583 | <!-- CommandArgs matches the items after a command --> | ||
| 574 | <context attribute="Normal Text" lineEndContext="#pop" name="CommandArgs"> | 584 | <context attribute="Normal Text" lineEndContext="#pop" name="CommandArgs"> | ||
| 575 | <LineContinue /> | 585 | <!-- In command arguments, do not allow comments after escaped characters. | ||
| 586 | This avoids highlighting comments within paths or other text. Ex: pathtext\ #no\ comment --> | ||||
| 587 | <!-- FindComments --> | ||||
| 588 | <RegExpr attribute="Control" context="#pop!Comment" String=";;?(?=#)" /> | ||||
| 589 | <IncludeRules context="FindCommentsInCommand" /> | ||||
| 590 | <IncludeRules context="FindMostWithoutComments" /> | ||||
| 591 | <IncludeRules context="DefaultCommandArgs" /> | ||||
| 592 | </context> | ||||
| 593 | <!-- CommandArgs but with normal comments --> | ||||
| 594 | <context attribute="Normal Text" lineEndContext="#pop" name="CommandArgsNormal"> | ||||
| 576 | <IncludeRules context="FindMost" /> | 595 | <IncludeRules context="FindMost" /> | ||
| 596 | <IncludeRules context="DefaultCommandArgs" /> | ||||
| 597 | </context> | ||||
| 598 | | ||||
| 599 | <context attribute="Normal Text" lineEndContext="#pop" name="DefaultCommandArgs"> | ||||
| 600 | <LineContinue /> | ||||
| 577 | <RegExpr attribute="Keyword" context="#stay" String="\\$" /> | 601 | <RegExpr attribute="Keyword" context="#stay" String="\\$" /> | ||
| 578 | <!-- handle keywords --> | 602 | <!-- handle keywords --> | ||
| 579 | <RegExpr attribute="Option" context="#stay" String="\.(?=\s)" /> | 603 | <RegExpr attribute="Option" context="#stay" String="\.(?=\s)" /> | ||
| 580 | <!-- handle here-string --> | 604 | <!-- handle here-string --> | ||
| 581 | <RegExpr attribute="Redirection" context="#stay" String="\d*<<<" /> | 605 | <RegExpr attribute="Redirection" context="#stay" String="\d*<<<" /> | ||
| 582 | <!-- handle here document --> | 606 | <!-- handle here document --> | ||
| 583 | <Detect2Chars attribute="Redirection" context="HereDoc" char="<" char1="<" lookAhead="true" /> | 607 | <Detect2Chars attribute="Redirection" context="HereDoc" char="<" char1="<" lookAhead="true" /> | ||
| 584 | <!-- handle process subst --> | 608 | <!-- handle process subst --> | ||
| 585 | <RegExpr attribute="Redirection" context="ProcessSubst" String="[<>]\(" /> | 609 | <RegExpr attribute="Redirection" context="ProcessSubst" String="[<>]\(" /> | ||
| 586 | <!-- handle redirection --> | 610 | <!-- handle redirection --> | ||
| 587 | <RegExpr attribute="Redirection" context="#stay" String="([0-9]*(>{1,2}|<)(&[0-9]+-?)?|&>|>&|[0-9]*<>)" /> | 611 | <RegExpr attribute="Redirection" context="#stay" String="([0-9]*(>{1,2}|<)(&[0-9]+-?)?|&>|>&|[0-9]*<>)" /> | ||
| 588 | <!-- handle &, &&, | and || --> | 612 | <!-- handle &, &&, |, ||, ; and ;; --> | ||
| 589 | <RegExpr attribute="Control" context="#pop" String="([|&;])\1?" /> | 613 | <RegExpr attribute="Control" context="#pop" String="([|&;])\1?" /> | ||
| 590 | <RegExpr attribute="Normal Text" context="#stay" String="[a-zA-Z_]+-[A-Za-z0-9_-]*" /> | 614 | <RegExpr attribute="Normal Text" context="#stay" String="[a-zA-Z_]+-[A-Za-z0-9_-]*" /> | ||
| 591 | <RegExpr attribute="Option" context="#stay" String="-?-[a-zA-Z_][A-Za-z0-9_-]*" /> | 615 | <RegExpr attribute="Option" context="#stay" String="-?-[a-zA-Z_][A-Za-z0-9_-]*" /> | ||
| 592 | <keyword attribute="Option" context="#stay" String="keywords" /> | 616 | <keyword attribute="Option" context="#stay" String="keywords" /> | ||
| 593 | <AnyChar String=")}" context="#pop" lookAhead="true"/> | 617 | <AnyChar String=")}" context="#pop" lookAhead="true"/> | ||
| 594 | </context> | 618 | </context> | ||
| 595 | 619 | | |||
| 596 | <!-- FindCommands matches many items that can be expected outside strings, substitutions etc, when inside a Backquote --> | 620 | <!-- FindCommands matches many items that can be expected outside strings, substitutions etc, when inside a Backquote --> | ||
| ▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines | |||||