117
117
/^ [ ] * !* [ ] * ( .. * ) [ ] * [0-9] * [<>|&] /b oneline
118
118
119
119
# multi-line "(...\n...)"
120
- /^ [ ] * ( /b subshell
120
+ /^ [ ] * ( /b subsh
121
121
122
122
# innocuous line -- print it and advance to next line
123
123
b
130
130
}
131
131
b
132
132
133
- : subshell
133
+ : subsh
134
134
# bare "(" line? -- stash for later printing
135
135
/^ [ ] * ( [ ] * $ / {
136
136
h
137
- b nextline
137
+ b nextln
138
138
}
139
139
# "(..." line -- split off and stash "(", then process "..." as its own line
140
140
x
143
143
s /( //
144
144
b slurp
145
145
146
- : nextline
146
+ : nextln
147
147
N
148
148
s /. * \n //
149
149
150
150
: slurp
151
151
# incomplete line "...\"
152
152
/\\ $ /b icmplte
153
153
# multi-line quoted string "...\n..."?
154
- /" /b dqstring
154
+ /" /b dqstr
155
155
# multi-line quoted string '...\n...'? (but not contraction in string "it's")
156
156
/' /{
157
- /"[^ '"] * '[^ '"] * " /! b sqstring
157
+ /"[^ '"] * '[^ '"] * " /! b sqstr
158
158
}
159
159
: folded
160
160
# here-doc -- swallow it
@@ -163,8 +163,8 @@ s/.*\n//
163
163
# before closing ")", "done", "elsif", "else", or "fi" will need to be
164
164
# re-visited to drop "suspect" marking since final line of those constructs
165
165
# legitimately lacks "&&", so "suspect" mark must be removed
166
- /^ [ ] * # /b nextline
167
- /^ [ ] * $ /b nextline
166
+ /^ [ ] * # /b nextln
167
+ /^ [ ] * $ /b nextln
168
168
# in-line comment -- strip it (but not "#" in a string, Bash ${#...} array
169
169
# length, or Perforce "//depot/path#42" revision in filespec)
170
170
/[ ] # /{
@@ -175,22 +175,22 @@ s/.*\n//
175
175
# multi-line "case ... esac"
176
176
/^ [ ] * case[ ] .. * [ ] in /b case
177
177
# multi-line "for ... done" or "while ... done"
178
- /^ [ ] * for[ ] .. * [ ] in /b continue
179
- /^ [ ] * while[ ] /b continue
180
- /^ [ ] * do[ ] /b continue
181
- /^ [ ] * do[ ] * $ /b continue
182
- /;[ ] * do /b continue
178
+ /^ [ ] * for[ ] .. * [ ] in /b cont
179
+ /^ [ ] * while[ ] /b cont
180
+ /^ [ ] * do[ ] /b cont
181
+ /^ [ ] * do[ ] * $ /b cont
182
+ /;[ ] * do /b cont
183
183
/^ [ ] * done[ ] * &&[ ] * $ /b done
184
184
/^ [ ] * done[ ] * $ /b done
185
185
/^ [ ] * done[ ] * [<>|] /b done
186
186
/^ [ ] * done[ ] * ) /b done
187
- /|| [ ] * exit[ ] /b continue
188
- /|| [ ] * exit[ ] * $ /b continue
187
+ /|| [ ] * exit[ ] /b cont
188
+ /|| [ ] * exit[ ] * $ /b cont
189
189
# multi-line "if...elsif...else...fi"
190
- /^ [ ] * if[ ] /b continue
191
- /^ [ ] * then[ ] /b continue
192
- /^ [ ] * then[ ] * $ /b continue
193
- /;[ ] * then /b continue
190
+ /^ [ ] * if[ ] /b cont
191
+ /^ [ ] * then[ ] /b cont
192
+ /^ [ ] * then[ ] * $ /b cont
193
+ /;[ ] * then /b cont
194
194
/^ [ ] * elif[ ] /b else
195
195
/^ [ ] * elif[ ] * $ /b else
196
196
/^ [ ] * else[ ] /b else
@@ -234,10 +234,10 @@ s/.*\n//
234
234
}
235
235
}
236
236
# line ends with pipe "...|" -- valid; not missing "&&"
237
- /| [ ] * $ /b continue
237
+ /| [ ] * $ /b cont
238
238
# missing end-of-line "&&" -- mark suspect
239
239
/&&[ ] * $ /! s /^ /?!AMP?! /
240
- : continue
240
+ : cont
241
241
# retrieve and print previous line
242
242
x
243
243
n
@@ -250,29 +250,29 @@ s/\\\n//
250
250
b slurp
251
251
252
252
# check for multi-line double-quoted string "...\n..." -- fold to one line
253
- : dqstring
253
+ : dqstr
254
254
# remove all quote pairs
255
255
s /"\( [^ "] * \) " /@!\1 @! /g
256
256
# done if no dangling quote
257
257
/" /! b dqdone
258
258
# otherwise, slurp next line and try again
259
259
N
260
260
s /\n //
261
- b dqstring
261
+ b dqstr
262
262
: dqdone
263
263
s /@! /" /g
264
264
b folded
265
265
266
266
# check for multi-line single-quoted string '...\n...' -- fold to one line
267
- : sqstring
267
+ : sqstr
268
268
# remove all quote pairs
269
269
s /'\( [^ '] * \) ' /@!\1 @! /g
270
270
# done if no dangling quote
271
271
/' /! b sqdone
272
272
# otherwise, slurp next line and try again
273
273
N
274
274
s /\n //
275
- b sqstring
275
+ b sqstr
276
276
: sqdone
277
277
s /@! /' /g
278
278
b folded
@@ -282,11 +282,11 @@ bfolded
282
282
: heredoc
283
283
s /^ \( . * \) <<[ ] * [-\\ '"] * \( [A-Za-z0-9_][A-Za-z0-9_] * \) ['"] * /<\2 >\1 << /
284
284
s /[ ] * << //
285
- : heredsub
285
+ : hdocsub
286
286
N
287
287
/^ <\( [^ >] * \) >. * \n [ ] * \1 [ ] * $ /! {
288
288
s /\n . * $ //
289
- b heredsub
289
+ b hdocsub
290
290
}
291
291
s /^ <[^ >] * > //
292
292
s /\n . * $ //
@@ -305,7 +305,7 @@ bcase
305
305
x
306
306
s /? !AMP? ! //
307
307
x
308
- b continue
308
+ b cont
309
309
310
310
# found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop
311
311
# "suspect" from final contained line since that line legitimately lacks "&&"
@@ -321,22 +321,22 @@ bchkchn
321
321
# found nested multi-line "(...\n...)" -- pass through untouched
322
322
: nest
323
323
x
324
- : nstslurp
324
+ : nstslrp
325
325
n
326
326
# closing ")" on own line -- stop nested slurp
327
- /^ [ ] * ) /b nstclose
327
+ /^ [ ] * ) /b nstcl
328
328
# comment -- not closing ")" if in comment
329
329
/^ [ ] * # /b nstcnt
330
330
# "$((...))" -- arithmetic expansion; not closing ")"
331
331
/\$ (( [^ )][^ )] * )) [^ )] * $ /b nstcnt
332
332
# "$(...)" -- command substitution; not closing ")"
333
333
/\$ ( [^ )][^ )] * ) [^ )] * $ /b nstcnt
334
334
# closing "...)" -- stop nested slurp
335
- /) /b nstclose
335
+ /) /b nstcl
336
336
: nstcnt
337
337
x
338
- b nstslurp
339
- : nstclose
338
+ b nstslrp
339
+ : nstcl
340
340
s /^ />> /
341
341
# is it "))" which closes nested and parent subshells?
342
342
/) [ ] * ) /b slurp
0 commit comments