9797/<<[ ] * [-\\ '] * [A-Za-z0-9_] / {
9898 s /^ \( . * \) <<[ ] * [-\\ '] * \( [A-Za-z0-9_][A-Za-z0-9_] * \) '* /<\2 >\1 << /
9999 s /[ ] * << //
100- : hereslurp
100+ : hered
101101 N
102102 /^ <\( [^ >] * \) >. * \n [ ] * \1 [ ] * $ /! {
103103 s /\n . * $ //
104- b hereslurp
104+ b hered
105105 }
106106 s /^ <[^ >] * > //
107107 s /\n . * $ //
@@ -149,7 +149,7 @@ s/.*\n//
149149
150150: slurp
151151# incomplete line "...\"
152- /\\ $ /b incomplete
152+ /\\ $ /b icmplte
153153# multi-line quoted string "...\n..."?
154154/" /b dqstring
155155# multi-line quoted string '...\n...'? (but not contraction in string "it's")
@@ -171,7 +171,7 @@ s/.*\n//
171171 /"[^ "] * #[^ "] * " /! s /[ ] #. * $ //
172172}
173173# one-liner "case ... esac"
174- /^ [ ] * case[ ] * .. * esac /b checkchain
174+ /^ [ ] * case[ ] * .. * esac /b chkchn
175175# multi-line "case ... esac"
176176/^ [ ] * case[ ] .. * [ ] in /b case
177177# multi-line "for ... done" or "while ... done"
@@ -200,32 +200,32 @@ s/.*\n//
200200/^ [ ] * fi[ ] * [<>|] /b done
201201/^ [ ] * fi[ ] * ) /b done
202202# nested one-liner "(...) &&"
203- /^ [ ] * ( . * ) [ ] * &&[ ] * $ /b checkchain
203+ /^ [ ] * ( . * ) [ ] * &&[ ] * $ /b chkchn
204204# nested one-liner "(...)"
205- /^ [ ] * ( . * ) [ ] * $ /b checkchain
205+ /^ [ ] * ( . * ) [ ] * $ /b chkchn
206206# nested one-liner "(...) >x" (or "2>x" or "<x" or "|x")
207- /^ [ ] * ( . * ) [ ] * [0-9] * [<>|] /b checkchain
207+ /^ [ ] * ( . * ) [ ] * [0-9] * [<>|] /b chkchn
208208# nested multi-line "(...\n...)"
209209/^ [ ] * ( /b nest
210210# multi-line "{...\n...}"
211211/^ [ ] * { /b block
212212# closing ")" on own line -- exit subshell
213- /^ [ ] * ) /b closesolo
213+ /^ [ ] * ) /b clssolo
214214# "$((...))" -- arithmetic expansion; not closing ")"
215- /\$ (( [^ )][^ )] * )) [^ )] * $ /b checkchain
215+ /\$ (( [^ )][^ )] * )) [^ )] * $ /b chkchn
216216# "$(...)" -- command substitution; not closing ")"
217- /\$ ( [^ )][^ )] * ) [^ )] * $ /b checkchain
217+ /\$ ( [^ )][^ )] * ) [^ )] * $ /b chkchn
218218# multi-line "$(...\n...)" -- command substitution; treat as nested subshell
219219/\$ ( [^ )] * $ /b nest
220220# "=(...)" -- Bash array assignment; not closing ")"
221- /=( /b checkchain
221+ /=( /b chkchn
222222# closing "...) &&"
223223/) [ ] * &&[ ] * $ /b close
224224# closing "...)"
225225/) [ ] * $ /b close
226226# closing "...) >x" (or "2>x" or "<x" or "|x")
227227/) [ ] * [<>|] /b close
228- : checkchain
228+ : chkchn
229229# mark suspect if line uses ";" internally rather than "&&" (but not ";" in a
230230# string and not ";;" in one-liner "case...esac")
231231/; /{
244244b slurp
245245
246246# found incomplete line "...\" -- slurp up next line
247- : incomplete
247+ : icmplte
248248N
249249s /\\ \n //
250250b slurp
@@ -282,11 +282,11 @@ bfolded
282282: heredoc
283283s /^ \( . * \) <<[ ] * [-\\ '] * \( [A-Za-z0-9_][A-Za-z0-9_] * \) '* /<\2 >\1 << /
284284s /[ ] * << //
285- : hereslurpsub
285+ : heredsub
286286N
287287/^ <\( [^ >] * \) >. * \n [ ] * \1 [ ] * $ /! {
288288 s /\n . * $ //
289- b hereslurpsub
289+ b heredsub
290290}
291291s /^ <[^ >] * > //
292292s /\n . * $ //
316316# is 'done' or 'fi' cuddled with ")" to close subshell?
317317/done. * ) /b close
318318/fi. * ) /b close
319- b checkchain
319+ b chkchn
320320
321321# found nested multi-line "(...\n...)" -- pass through untouched
322322: nest
323323x
324- : nestslurp
324+ : nstslurp
325325n
326326# closing ")" on own line -- stop nested slurp
327- /^ [ ] * ) /b nestclose
327+ /^ [ ] * ) /b nstclose
328328# comment -- not closing ")" if in comment
329- /^ [ ] * # /b nestcontinue
329+ /^ [ ] * # /b nstcnt
330330# "$((...))" -- arithmetic expansion; not closing ")"
331- /\$ (( [^ )][^ )] * )) [^ )] * $ /b nestcontinue
331+ /\$ (( [^ )][^ )] * )) [^ )] * $ /b nstcnt
332332# "$(...)" -- command substitution; not closing ")"
333- /\$ ( [^ )][^ )] * ) [^ )] * $ /b nestcontinue
333+ /\$ ( [^ )][^ )] * ) [^ )] * $ /b nstcnt
334334# closing "...)" -- stop nested slurp
335- /) /b nestclose
336- : nestcontinue
335+ /) /b nstclose
336+ : nstcnt
337337x
338- b nestslurp
339- : nestclose
338+ b nstslurp
339+ : nstclose
340340s /^ />> /
341341# is it "))" which closes nested and parent subshells?
342342/) [ ] * ) /b slurp
343- b checkchain
343+ b chkchn
344344
345345# found multi-line "{...\n...}" block -- pass through untouched
346346: block
347347x
348348n
349349# closing "}" -- stop block slurp
350- /} /b checkchain
350+ /} /b chkchn
351351b block
352352
353353# found closing ")" on own line -- drop "suspect" from final line of subshell
354354# since that line legitimately lacks "&&" and exit subshell loop
355- : closesolo
355+ : clssolo
356356x
357357s /? !AMP? ! //
358358p
0 commit comments