chainlint: let here-doc and multi-line string commence on same line
commitd93871143fdb7c11ddea81aa7f698e5eee0246e5
authorEric Sunshine <sunshine@sunshineco.com>
Mon, 13 Aug 2018 08:47:37 +0000 (13 04:47 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Aug 2018 19:22:12 +0000 (13 12:22 -0700)
tree1f773aa5dbcb210176a75483e6594d76e84bb09f
parent06fc5c9f90da9be18371bafad5f35b6b17cbf49e
chainlint: let here-doc and multi-line string commence on same line

After swallowing a here-doc, chainlint.sed assumes that no other
processing needs to be done on the line aside from checking for &&-chain
breakage; likewise, after folding a multi-line quoted string. However,
it's conceivable (even if unlikely in practice) that both a here-doc and
a multi-line quoted string might commence on the same line:

    cat <<\EOF && echo "foo
    bar"
    data
    EOF

Support this case by sending the line (after swallowing and folding)
through the normal processing sequence rather than jumping directly to
the check for broken &&-chain.

This change also allows other somewhat pathological cases to be handled,
such as closing a subshell on the same line starting a here-doc:

    (
        cat <<-\INPUT)
        data
        INPUT

or, for instance, opening a multi-line $(...) expression on the same
line starting a here-doc:

    x=$(cat <<-\END &&
        data
        END
        echo "x")

among others.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/chainlint.sed
t/chainlint/here-doc-close-subshell.expect [new file with mode: 0644]
t/chainlint/here-doc-close-subshell.test [new file with mode: 0644]
t/chainlint/here-doc-multi-line-command-subst.expect [new file with mode: 0644]
t/chainlint/here-doc-multi-line-command-subst.test [new file with mode: 0644]
t/chainlint/here-doc-multi-line-string.expect [new file with mode: 0644]
t/chainlint/here-doc-multi-line-string.test [new file with mode: 0644]