97
97
/<<[ ] * [-\\ '] * [A-Za-z0-9_] / {
98
98
s /^ \( . * \) <<[ ] * [-\\ '] * \( [A-Za-z0-9_][A-Za-z0-9_] * \) '* /<\2 >\1 << /
99
99
s /[ ] * << //
100
- : hereslurp
100
+ : hered
101
101
N
102
102
/^ <\( [^ >] * \) >. * \n [ ] * \1 [ ] * $ /! {
103
103
s /\n . * $ //
104
- b hereslurp
104
+ b hered
105
105
}
106
106
s /^ <[^ >] * > //
107
107
s /\n . * $ //
@@ -149,7 +149,7 @@ s/.*\n//
149
149
150
150
: slurp
151
151
# incomplete line "...\"
152
- /\\ $ /b incomplete
152
+ /\\ $ /b icmplte
153
153
# multi-line quoted string "...\n..."?
154
154
/" /b dqstring
155
155
# multi-line quoted string '...\n...'? (but not contraction in string "it's")
@@ -171,7 +171,7 @@ s/.*\n//
171
171
/"[^ "] * #[^ "] * " /! s /[ ] #. * $ //
172
172
}
173
173
# one-liner "case ... esac"
174
- /^ [ ] * case[ ] * .. * esac /b checkchain
174
+ /^ [ ] * case[ ] * .. * esac /b chkchn
175
175
# multi-line "case ... esac"
176
176
/^ [ ] * case[ ] .. * [ ] in /b case
177
177
# multi-line "for ... done" or "while ... done"
@@ -200,32 +200,32 @@ s/.*\n//
200
200
/^ [ ] * fi[ ] * [<>|] /b done
201
201
/^ [ ] * fi[ ] * ) /b done
202
202
# nested one-liner "(...) &&"
203
- /^ [ ] * ( . * ) [ ] * &&[ ] * $ /b checkchain
203
+ /^ [ ] * ( . * ) [ ] * &&[ ] * $ /b chkchn
204
204
# nested one-liner "(...)"
205
- /^ [ ] * ( . * ) [ ] * $ /b checkchain
205
+ /^ [ ] * ( . * ) [ ] * $ /b chkchn
206
206
# nested one-liner "(...) >x" (or "2>x" or "<x" or "|x")
207
- /^ [ ] * ( . * ) [ ] * [0-9] * [<>|] /b checkchain
207
+ /^ [ ] * ( . * ) [ ] * [0-9] * [<>|] /b chkchn
208
208
# nested multi-line "(...\n...)"
209
209
/^ [ ] * ( /b nest
210
210
# multi-line "{...\n...}"
211
211
/^ [ ] * { /b block
212
212
# closing ")" on own line -- exit subshell
213
- /^ [ ] * ) /b closesolo
213
+ /^ [ ] * ) /b clssolo
214
214
# "$((...))" -- arithmetic expansion; not closing ")"
215
- /\$ (( [^ )][^ )] * )) [^ )] * $ /b checkchain
215
+ /\$ (( [^ )][^ )] * )) [^ )] * $ /b chkchn
216
216
# "$(...)" -- command substitution; not closing ")"
217
- /\$ ( [^ )][^ )] * ) [^ )] * $ /b checkchain
217
+ /\$ ( [^ )][^ )] * ) [^ )] * $ /b chkchn
218
218
# multi-line "$(...\n...)" -- command substitution; treat as nested subshell
219
219
/\$ ( [^ )] * $ /b nest
220
220
# "=(...)" -- Bash array assignment; not closing ")"
221
- /=( /b checkchain
221
+ /=( /b chkchn
222
222
# closing "...) &&"
223
223
/) [ ] * &&[ ] * $ /b close
224
224
# closing "...)"
225
225
/) [ ] * $ /b close
226
226
# closing "...) >x" (or "2>x" or "<x" or "|x")
227
227
/) [ ] * [<>|] /b close
228
- : checkchain
228
+ : chkchn
229
229
# mark suspect if line uses ";" internally rather than "&&" (but not ";" in a
230
230
# string and not ";;" in one-liner "case...esac")
231
231
/; /{
244
244
b slurp
245
245
246
246
# found incomplete line "...\" -- slurp up next line
247
- : incomplete
247
+ : icmplte
248
248
N
249
249
s /\\ \n //
250
250
b slurp
@@ -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
- : hereslurpsub
285
+ : heredsub
286
286
N
287
287
/^ <\( [^ >] * \) >. * \n [ ] * \1 [ ] * $ /! {
288
288
s /\n . * $ //
289
- b hereslurpsub
289
+ b heredsub
290
290
}
291
291
s /^ <[^ >] * > //
292
292
s /\n . * $ //
316
316
# is 'done' or 'fi' cuddled with ")" to close subshell?
317
317
/done. * ) /b close
318
318
/fi. * ) /b close
319
- b checkchain
319
+ b chkchn
320
320
321
321
# found nested multi-line "(...\n...)" -- pass through untouched
322
322
: nest
323
323
x
324
- : nestslurp
324
+ : nstslurp
325
325
n
326
326
# closing ")" on own line -- stop nested slurp
327
- /^ [ ] * ) /b nestclose
327
+ /^ [ ] * ) /b nstclose
328
328
# comment -- not closing ")" if in comment
329
- /^ [ ] * # /b nestcontinue
329
+ /^ [ ] * # /b nstcnt
330
330
# "$((...))" -- arithmetic expansion; not closing ")"
331
- /\$ (( [^ )][^ )] * )) [^ )] * $ /b nestcontinue
331
+ /\$ (( [^ )][^ )] * )) [^ )] * $ /b nstcnt
332
332
# "$(...)" -- command substitution; not closing ")"
333
- /\$ ( [^ )][^ )] * ) [^ )] * $ /b nestcontinue
333
+ /\$ ( [^ )][^ )] * ) [^ )] * $ /b nstcnt
334
334
# closing "...)" -- stop nested slurp
335
- /) /b nestclose
336
- : nestcontinue
335
+ /) /b nstclose
336
+ : nstcnt
337
337
x
338
- b nestslurp
339
- : nestclose
338
+ b nstslurp
339
+ : nstclose
340
340
s /^ />> /
341
341
# is it "))" which closes nested and parent subshells?
342
342
/) [ ] * ) /b slurp
343
- b checkchain
343
+ b chkchn
344
344
345
345
# found multi-line "{...\n...}" block -- pass through untouched
346
346
: block
347
347
x
348
348
n
349
349
# closing "}" -- stop block slurp
350
- /} /b checkchain
350
+ /} /b chkchn
351
351
b block
352
352
353
353
# found closing ")" on own line -- drop "suspect" from final line of subshell
354
354
# since that line legitimately lacks "&&" and exit subshell loop
355
- : closesolo
355
+ : clssolo
356
356
x
357
357
s /? !AMP? ! //
358
358
p
0 commit comments