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
|
From f6607c869cf0f5113d657f713fc35fd66a13b8f1 Mon Sep 17 00:00:00 2001
From: Jonathan Poelen <jonathan.poelen@gmail.com>
Date: Sun, 6 Dec 2020 16:25:16 +0000
Subject: [PATCH] Bash: add (...), ||, && in [[ ... ]] ; add backquote in [ ...
] and [[ ... ]]
---
data/syntax/bash.xml | 72 ++++++++++++++++++---------
6 files changed, 84 insertions(+), 23 deletions(-)
diff --git a/data/syntax/bash.xml b/data/syntax/bash.xml
index f76b008c..3b8824df 100644
--- a/data/syntax/bash.xml
+++ b/data/syntax/bash.xml
@@ -28,7 +28,7 @@
<!ENTITY heredocq "(?|"([^"]+)"|'([^']+)'|\\(.[^&wordseps;&substseps;]*))">
]>
-<language name="Bash" version="15" kateversion="5.62" 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">
+<language name="Bash" version="16" kateversion="5.62" 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">
<!-- (c) 2004 by Wilbert Berendsen (wilbert@kde.nl)
Changes by Matthew Woehlke (mw_triad@users.sourceforge.net)
@@ -495,7 +495,7 @@
</context>
<context attribute="Normal Text" lineEndContext="#pop" name="MaybeBracketExpression" fallthroughContext="#pop!Command">
<!-- start expression in double brackets -->
- <RegExpr attribute="Keyword" context="ExprDblBracket" String="\[\[&eos;" beginRegion="expression"/>
+ <RegExpr attribute="Keyword" context="ExprDblBracket" String="\[\[(?=$|[ &tab;(])" beginRegion="expression"/>
<!-- start expression in single brackets -->
<RegExpr attribute="Builtin" context="ExprBracket" String="\[&eos;" beginRegion="expression"/>
</context>
@@ -642,6 +642,9 @@
<IncludeRules context="FindWord"/>
<DetectChar context="NormalMaybeBraceExpansion" char="{" lookAhead="1"/>
<IncludeRules context="FindPathThenPop"/>
+ <IncludeRules context="FindNormalTextOption"/>
+ </context>
+ <context attribute="Normal Text" lineEndContext="#stay" name="FindNormalTextOption">
<RegExpr attribute="Normal Text" context="#stay" String="[^&wordseps;&substseps;]+"/>
</context>
<context attribute="Normal Text" lineEndContext="#pop" name="OptionMaybeBraceExpansion">
@@ -1146,33 +1149,40 @@
<context attribute="Normal Text" lineEndContext="#stay" name="ExprBracketNot" fallthroughContext="#pop!ExprBracketParam1">
<DetectSpaces attribute="Normal Text" context="#pop!ExprBracketParam1"/>
- <DetectChar context="ExprBracketTestMaybeNot" char="!" lookAhead="1"/>
+ <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" fallthroughContext="#pop#pop!ExprBracketParam1">
- <RegExpr attribute="Expression" context="#pop" String="!(?=[ &tab;])"/>
+ <context attribute="Normal Text" lineEndContext="#pop" name="ExprBracketTestMaybeNot">
+ <DetectChar attribute="Expression" context="#pop" char="!"/>
</context>
- <context attribute="Normal Text" lineEndContext="#stay" name="ExprBracketParam1" fallthroughContext="NormalOption">
+ <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 attribute="Error" context="#stay" String="&symbolseps;"/>
+ <AnyChar context="#pop" String=" &tab;" lookAhead="1"/>
+ <IncludeRules context="FindWord"/>
+ <DetectChar context="NormalMaybeBraceExpansion" char="{" lookAhead="1"/>
+ <IncludeRules context="FindPathThenPop"/>
+ <IncludeRules context="FindNormalTextOption"/>
</context>
- <context attribute="Normal Text" lineEndContext="#stay" name="ExprBracketParam2" fallthroughContext="NormalOption">
+ <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"/>
- <AnyChar attribute="Error" context="#stay" String="&symbolseps;"/>
</context>
- <context attribute="Normal Text" lineEndContext="ExprBracketFinal" name="ExprBracketParam3" fallthroughContext="NormalOption">
+ <context attribute="Normal Text" lineEndContext="ExprBracketFinal" name="ExprBracketParam3" fallthroughContext="ExprBracketValue">
<DetectSpaces attribute="Normal Text" context="#pop!ExprBracketFinal"/>
<IncludeRules context="FindExprBracketEnd"/>
- <AnyChar attribute="Error" context="#stay" String="&symbolseps;"/>
</context>
- <context attribute="Normal Text" lineEndContext="#stay" name="ExprBracketFinal" fallthroughContext="NormalOption">
+ <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"/>
@@ -1183,10 +1193,10 @@
<RegExpr attribute="Builtin" context="#pop" String="\](?=($|[ &tab;;|&<>]))" endRegion="expression"/>
</context>
- <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeUnary" fallthroughContext="#pop!NormalOption">
+ <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeUnary" fallthroughContext="#pop!ExprBracketValue">
<RegExpr attribute="Expression" context="#pop" String="-[abcdefghkprstuwxGLNOSovRnz](?=[ &tab;])"/>
</context>
- <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeBinary" fallthroughContext="#pop!NormalOption">
+ <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeBinary" fallthroughContext="#pop!ExprBracketValue">
<RegExpr attribute="Expression" context="#pop" String="(?:-(?:e[fq]|[nolg]t|[nlg]e)|==?|!=)(?=[ &tab;])"/>
</context>
@@ -1202,40 +1212,56 @@
<DetectChar context="ExprDblBracketTestMaybeNot" char="!" lookAhead="1"/>
</context>
<context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketTestMaybeNot" fallthroughContext="#pop#pop!ExprDblBracketParam1">
- <IncludeRules context="ExprBracketTestMaybeNot"/>
+ <RegExpr attribute="Expression" context="#pop" String="!(?=$|[ &tab;(])"/>
</context>
- <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam1" fallthroughContext="NormalOption">
+ <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam1" fallthroughContext="ExprDblBracketValue">
<DetectSpaces attribute="Normal Text" context="#pop!ExprDblBracketParam2"/>
<DetectChar context="TestMaybeUnary" char="-" lookAhead="1"/>
<AnyChar attribute="Expression" context="#pop!ExprDblBracketParam3Spe" String="<>"/>
<IncludeRules context="FindExprDblBracketEnd"/>
- <AnyChar attribute="Error" context="#stay" String="&symbolseps;"/>
</context>
- <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam2" fallthroughContext="NormalOption">
+ <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketValue">
+ <Detect2Chars attribute="Keyword" context="ExprDblParen" char="(" char1="(" beginRegion="expression"/>
+ <DetectChar context="ExprDblBracketSubValue" char="(" lookAhead="1"/>
+ <DetectChar attribute="Operator" context="#pop#pop" char=")"/>
+ <Detect2Chars attribute="Control" context="#pop#pop!ExprDblBracket" char="&" char1="&"/>
+ <Detect2Chars attribute="Control" context="#pop#pop!ExprDblBracket" char="|" char1="|"/>
+ <AnyChar attribute="Error" context="#stay" String="|&;)"/>
+ <AnyChar context="#pop" String=" &tab;<>" lookAhead="1"/>
+ <IncludeRules context="FindWord"/>
+ <DetectChar context="NormalMaybeBraceExpansion" char="{" lookAhead="1"/>
+ <IncludeRules context="FindPathThenPop"/>
+ <IncludeRules context="FindNormalTextOption"/>
+ </context>
+ <context attribute="Normal Text" lineEndContext="#pop" name="ExprDblBracketSubValue" fallthroughContext="#pop">
+ <DetectChar attribute="Operator" context="ExprDblBracketNot" char="("/>
+ <Detect2Chars context="#pop#pop" char="]" char1="]" lookAhead="1"/>
+ </context>
+
+ <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketParam2" fallthroughContext="ExprDblBracketValue">
<DetectSpaces attribute="Normal Text" context="#pop!ExprDblBracketParam3"/>
<AnyChar context="TestMaybeBinary2" String="-=!" lookAhead="1"/>
<AnyChar attribute="Expression" context="#pop!ExprDblBracketParam3Spe" String="<>"/>
<IncludeRules context="FindExprDblBracketEnd"/>
- <AnyChar attribute="Error" context="#stay" String="&symbolseps;"/>
</context>
- <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeBinary2" fallthroughContext="#pop!NormalOption">
+ <context attribute="Normal Text" lineEndContext="#pop" name="TestMaybeBinary2" fallthroughContext="#pop!ExprDblBracketValue">
<IncludeRules context="TestMaybeBinary"/>
- <RegExpr attribute="Expression" context="#pop#pop!ExprDblBracketRegex" String="=~(?=[ &tab;])"/>
+ <RegExpr attribute="Expression" context="#pop#pop!ExprDblBracketRegex" String="=~(?=[ &tab;(])"/>
</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="ExprDblBracketFinal" name="ExprDblBracketParam3" fallthroughContext="NormalOption">
+ <context attribute="Normal Text" lineEndContext="ExprDblBracketFinal" name="ExprDblBracketParam3" fallthroughContext="ExprDblBracketValue">
<DetectSpaces attribute="Normal Text" context="#pop!ExprDblBracketFinal"/>
<IncludeRules context="FindExprDblBracketEnd"/>
- <AnyChar attribute="Error" context="#stay" String="&symbolseps;"/>
+ <AnyChar attribute="Error" context="#stay" String="<>"/>
</context>
- <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketFinal" fallthroughContext="NormalOption">
+ <context attribute="Normal Text" lineEndContext="#stay" name="ExprDblBracketFinal" fallthroughContext="ExprDblBracketValue">
<DetectSpaces attribute="Normal Text" context="#stay"/>
<IncludeRules context="FindExprDblBracketEnd"/>
<RegExpr attribute="Error" context="#pop" String="(?:[^] &tab;]++|\](?:[^]]|\][^ &tab;]))++" endRegion="expression"/>
--
GitLab
|