|
24 | 24 | # in order to avoid misinterpreting the ")" in constructs such as "x=$(...)"
|
25 | 25 | # and "case $x in *)" as ending the subshell.
|
26 | 26 | #
|
27 |
| -# Lines missing a final "&&" are flagged with "?!AMP?!", and lines which chain |
28 |
| -# commands with ";" internally rather than "&&" are flagged "?!SEMI?!". A line |
29 |
| -# may be flagged for both violations. |
| 27 | +# Lines missing a final "&&" are flagged with "?!AMP?!", as are lines which |
| 28 | +# chain commands with ";" internally rather than "&&". A line may be flagged |
| 29 | +# for both violations. |
30 | 30 | #
|
31 | 31 | # Detection of a missing &&-link in a multi-line subshell is complicated by the
|
32 | 32 | # fact that the last statement before the closing ")" must not end with "&&".
|
|
47 | 47 | # "?!AMP?!" violation is removed from the "bar" line (retrieved from the "hold"
|
48 | 48 | # area) since the final statement of a subshell must not end with "&&". The
|
49 | 49 | # final line of a subshell may still break the &&-chain by using ";" internally
|
50 |
| -# to chain commands together rather than "&&", so "?!SEMI?!" is not removed |
51 |
| -# from such a line; however, if the line ends with "?!SEMI?!", then the ";" is |
52 |
| -# harmless and the annotation is removed. |
| 50 | +# to chain commands together rather than "&&", but an internal "?!AMP?!" is |
| 51 | +# never removed from a line even though a line-ending "?!AMP?!" might be. |
53 | 52 | #
|
54 | 53 | # Care is taken to recognize the last _statement_ of a multi-line subshell, not
|
55 | 54 | # necessarily the last textual _line_ within the subshell, since &&-chaining
|
|
127 | 126 | # "&&" (but not ";" in a string)
|
128 | 127 | :oneline
|
129 | 128 | /;/{
|
130 |
| - /"[^"]*;[^"]*"/!s/;/; ?!SEMI?!/ |
| 129 | + /"[^"]*;[^"]*"/!s/;/; ?!AMP?!/ |
131 | 130 | }
|
132 | 131 | b
|
133 | 132 |
|
@@ -231,7 +230,7 @@ s/.*\n//
|
231 | 230 | # string and not ";;" in one-liner "case...esac")
|
232 | 231 | /;/{
|
233 | 232 | /;;/!{
|
234 |
| - /"[^"]*;[^"]*"/!s/;/; ?!SEMI?!/ |
| 233 | + /"[^"]*;[^"]*"/!s/;/; ?!AMP?!/ |
235 | 234 | }
|
236 | 235 | }
|
237 | 236 | # line ends with pipe "...|" -- valid; not missing "&&"
|
@@ -304,15 +303,15 @@ bcase
|
304 | 303 | # that line legitimately lacks "&&"
|
305 | 304 | :else
|
306 | 305 | x
|
307 |
| -s/\( ?!SEMI?!\)* ?!AMP?!$// |
| 306 | +s/\( ?!AMP?!\)* ?!AMP?!$// |
308 | 307 | x
|
309 | 308 | bcont
|
310 | 309 |
|
311 | 310 | # found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop
|
312 | 311 | # "suspect" from final contained line since that line legitimately lacks "&&"
|
313 | 312 | :done
|
314 | 313 | x
|
315 |
| -s/\( ?!SEMI?!\)* ?!AMP?!$// |
| 314 | +s/\( ?!AMP?!\)* ?!AMP?!$// |
316 | 315 | x
|
317 | 316 | # is 'done' or 'fi' cuddled with ")" to close subshell?
|
318 | 317 | /done.*)/bclose
|
@@ -355,7 +354,7 @@ bblock
|
355 | 354 | # since that line legitimately lacks "&&" and exit subshell loop
|
356 | 355 | :clssolo
|
357 | 356 | x
|
358 |
| -s/\( ?!SEMI?!\)* ?!AMP?!$// |
| 357 | +s/\( ?!AMP?!\)* ?!AMP?!$// |
359 | 358 | p
|
360 | 359 | x
|
361 | 360 | s/^/>/
|
|
0 commit comments