diff options
-rw-r--r-- | t/chainlint.sed | 21 | ||||
-rw-r--r-- | t/chainlint/block-comment.expect | 6 | ||||
-rw-r--r-- | t/chainlint/block-comment.test | 8 | ||||
-rw-r--r-- | t/chainlint/case-comment.expect | 8 | ||||
-rw-r--r-- | t/chainlint/case-comment.test | 11 | ||||
-rw-r--r-- | t/chainlint/nested-subshell-comment.expect | 2 |
6 files changed, 52 insertions, 4 deletions
diff --git a/t/chainlint.sed b/t/chainlint.sed index 0e575c0c62..b1505ef2cd 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -294,6 +294,12 @@ bfolded x s/?!HERE?!/<</g n +:cascom +/^[ ]*#/{ + N + s/.*\n// + bcascom +} /^[ ]*esac/bslurp bcase @@ -322,10 +328,15 @@ x :nstslrp s/?!HERE?!/<</g n +:nstcom +# comment -- not closing ")" if in comment +/^[ ]*#/{ + N + s/.*\n// + bnstcom +} # closing ")" on own line -- stop nested slurp /^[ ]*)/bnstcl -# comment -- not closing ")" if in comment -/^[ ]*#/bnstcnt # "$((...))" -- arithmetic expansion; not closing ")" /\$(([^)][^)]*))[^)]*$/bnstcnt # "$(...)" -- command substitution; not closing ")" @@ -345,6 +356,12 @@ bchkchn x s/?!HERE?!/<</g n +:blkcom +/^[ ]*#/{ + N + s/.*\n// + bblkcom +} # closing "}" -- stop block slurp /}/bchkchn bblock diff --git a/t/chainlint/block-comment.expect b/t/chainlint/block-comment.expect new file mode 100644 index 0000000000..d10b2eeaf2 --- /dev/null +++ b/t/chainlint/block-comment.expect @@ -0,0 +1,6 @@ +( + { + echo a && + echo b + } +) diff --git a/t/chainlint/block-comment.test b/t/chainlint/block-comment.test new file mode 100644 index 0000000000..df2beea888 --- /dev/null +++ b/t/chainlint/block-comment.test @@ -0,0 +1,8 @@ +( + { + # show a + echo a && + # show b + echo b + } +) diff --git a/t/chainlint/case-comment.expect b/t/chainlint/case-comment.expect new file mode 100644 index 0000000000..1e4b054bda --- /dev/null +++ b/t/chainlint/case-comment.expect @@ -0,0 +1,8 @@ +( + case "$x" in + x) foo ;; + *) + bar + ;; + esac +) diff --git a/t/chainlint/case-comment.test b/t/chainlint/case-comment.test new file mode 100644 index 0000000000..641c157b98 --- /dev/null +++ b/t/chainlint/case-comment.test @@ -0,0 +1,11 @@ +( + case "$x" in + # found foo + x) foo ;; + # found other + *) + # treat it as bar + bar + ;; + esac +) diff --git a/t/chainlint/nested-subshell-comment.expect b/t/chainlint/nested-subshell-comment.expect index 9138cf386d..be4b27a305 100644 --- a/t/chainlint/nested-subshell-comment.expect +++ b/t/chainlint/nested-subshell-comment.expect @@ -2,8 +2,6 @@ foo && ( bar && - # bottles wobble while fiddles gobble - # minor numbers of cows (or do they?) baz && snaff ) ?!AMP?! |