-
Notifications
You must be signed in to change notification settings - Fork 4
/
sh.jsf.in
332 lines (279 loc) · 5.39 KB
/
sh.jsf.in
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
# JOE syntax highlight file for sh/ksh/bash
# Think about:
# $'....'
# $(...)
# ${...}
# cat <<EOF xxxxxx
# xxxxx should be interpreted as other arguments for 'cat'.
# Colors
=Idle
=Comment green
=Constant cyan
=Escape bold cyan
=Keyword bold
=Var magenta
# Syntax
:idle Idle
* idle
# ")" subst_char recolor=-1
"`" subst_char recolor=-1
"#" comment recolor=-1
"\\" escape recolor=-1
"$" subst recolor=-1
"'" string_sq recolor=-1
"\"" string_dq recolor=-1
"<" maybe_inc
"a-zA-Z{}![_" ident buffer
:subst_char Var
* idle noeat
:maybe_inc Idle
* idle noeat
"<" maybe_inc1
:maybe_inc1 Idle
* inc buffer noeat
"\"" inc_quote
"'" inc_quote
" " maybe_inc1
"\n" toeof
"`&()\\|;<>" idle noeat
"\\" skipquote
"-" skipminus
:skipminus Idle
* inc1 buffer noeat
" " skipminus
"\\" skipquote
"\"" inc1_quote
"'" inc1_quote
"`&()\\|;<>\n" idle noeat
:skipquote Idle
* inc buffer noeat
"`&()\\|;'\"<> \n" idle noeat
# All of these are for case of leading -
:inc1 Var
* inc1
"`&()\\|;'\"<> \n" skipline1 noeat save_s
:inc1_quote Var
* inc1 buffer noeat
:skipline1 Idle
* skipline1
"\n" next_line1
:todelim1 Constant
* todelim1
"\n" next_line1 strings
"&" founddelim1
done
:next_line1 Constant
* todelim1 buffer
"\t" next_line1
"\n" next_line1
:founddelim1 Var
* idle noeat
# No leading -
:inc Var
* inc
"`&()\\|;'\"<> \n" skipline noeat save_s
:inc_quote Var
* inc noeat buffer
# Should be treated as a normal line here...
:skipline Idle
* skipline
"\n" next_line
:todelim Constant
* todelim
"\n" next_line strings
"&" founddelim
done
# eat \n so it's not in string.
:next_line Constant
* todelim buffer
"\n" next_line
:founddelim Var
* idle noeat
# << with no word. Rest of file is a constant.
:toeof Constant
* toeof
:comment Comment
* comment
"\n" idle
:escape Escape
* idle
:subst Var
* idle noeat
"(" idle recolor=-2 # don't try for now
"\"" string_dq recolor=-2
"\'" string_sq recolor=-2
"{" subst_brack
"a-zA-Z_" subst_name
"0-9*@?\-$_!#" idle
:subst_name Var
* idle noeat recolor=-1
"a-zA-Z0-9_" subst_name
:subst_brack Var
* subst_brack
"}" idle
# Simplest case: no quoting allowed
:string_sq Constant
* string_sq
"\'" idle
# double-quote: quoting, backqoutes and substitution allowed
:string_dq Constant
* string_dq
"$" string_dq_subst recolor=-1
"\"" idle
"\\" string_dq_esc recolor=-1
"`" string_dq_bq recolor=-1
:string_dq_subst Var
* string_dq noeat recolor=-2
"$0-9!_\-?*@" string_dq
"a-zA-Z_" string_dq_subst_name
"{" string_dq_subst_brack
:string_dq_subst_name Var
* string_dq recolor=-1 noeat
"a-zA-Z0-9_" string_dq_subst_name
:string_dq_subst_brack Var
* string_dq_subst_brack
"}" string_dq
:string_dq_esc Escape
* string_dq recolor=-2
"$`\"\\" string_dq
"\n" string_dq recolor=-2
:string_dq_bq Constant
* string_dq_bq
"$" string_dq_bq_subst recolor=-1
"\`" string_dq
"\\" string_dq_bq_esc recolor=-1
:string_dq_bq_subst Var
* string_dq_bq noeat recolor=-2
"$0-9!_\-?*@" string_dq_bq
"a-zA-Z_" string_dq_bq_subst_name
"{" string_dq_bq_subst_brack
:string_dq_bq_subst_name Var
* string_dq_bq recolor=-1 noeat
"a-zA-Z0-9_" string_dq_bq_subst_name
:string_dq_bq_subst_brack Var
* string_dq_bq_subst_brack
"}" string_dq_bq
:string_dq_bq_esc Escape
* string_dq_bq recolor=-2
"$`\"\\" string_dq_bq
"\n" string_dq_bq recolor=-2
# backquote
:string_bq Constant
* string_bq
"$" string_bq_subst recolor=-1
"\`" idle
"\\" string_bq_esc recolor=-1
# escape in backquote
:string_bq_esc Escape
* string_bq recolor=-2
"$`\"\\" string_bq
"\n" string_bq recolor=-2
# Substitution in a backquote
:string_bq_subst Var
* string_bq noeat recolor=-2
"$0-9!_\-?*@" string_bq
"a-zA-Z_" string_bq_subst_name
"{" string_bq_subst_brack
:string_bq_subst_name Var
* string_bq recolor=-1 noeat
"a-zA-Z0-9_" string_bq_subst_name
:string_bq_subst_brack Var
* string_bq_subst_brack
"}" string_bq
:ident Idle
* idle noeat strings
"!" kw
"{" kw
"}" kw
"[" kw
"]" kw
# primary keywords
"case" kw
"do" kw
"done" kw
"elif" kw
"else" kw
"esac" kw
"fi" kw
"for" kw
"if" kw
"in" kw
"then" kw
"until" kw
"while" kw
# I think these are basically keywords too
"break" kw
"continue" kw
"return" kw
"eval" kw
"exec" kw
"exit" kw
"test" kw # doesn't have to be a shell command
# variable management
"shift" kw
"unset" kw
"export" kw
"readonly" kw
# input
"read" kw
# job control (not likely to be used in scripts)
"bg" kw
"fg" kw
"jobs" kw
"suspend" kw
# job control (useful in scripts)
"kill" kw
"wait" kw
# environment control
"cd" kw
"chdir" kw
"pwd" kw
"ulimit" kw
"umask" kw
# signal handling
"trap" kw
# misc shell control
"hash" kw
"type" kw
"times" kw
"set" kw
# shell builtins
"echo" kw
"getopts" kw
"login" kw # not bash (logout is)
"newgrp" kw # not in bash
"stop" kw # not in bash (suspends a process)
# additional ksh builtins
"alias" kw
"select" kw
"function" kw
"command" kw
"fc" kw
"let" kw
"print" kw
"unalias" kw
"whence" kw
"history" kw
"time" kw
"typeset" kw
"local" kw
# additional bash builtins
"source" kw
"bind" kw
"builtin" kw
"compgen" kw
"complete" kw
"declare" kw
"dirs" kw
"disown" kw
"enable" kw
"help" kw
"logout" kw
"popd" kw
"printf" kw
"pushd" kw
"shopt" kw
done
"a-zA-Z0-9_" ident
:kw Keyword
* idle noeat