We found a few run-away here documents that are started with an end-of-here-doc marker that is incorrectly spelled, e.g. git some command >actual && cat <<EOF >expect ... EOF && test_cmp expect actual which ends up slurping the entire remainder of the script as if it were the data. Often the command that gets misused like this exits without failure (e.g. "cat" in the above example), which makes the command appear to work, without eve executing the remainder of the test. Use a trick similar to the one used to catch the &&-chain breakage to detect this case. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- * This catches all the cases detected in the recent discussion, I think. t/test-lib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/t/test-lib.sh b/t/test-lib.sh index 86d77c16dd..97bdc91f54 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -627,6 +627,10 @@ test_run_ () { test_eval_ "(exit 117) && $1" if test "$?" != 117; then error "bug in the test script: broken &&-chain: $1" + elif ! OK=$(test_eval_ "false && $1${LF}${LF}echo OK" 2>/dev/null) || + test OK != "$OK" + then + error "bug in the test script: possibly unterminated HERE-DOC" fi trace=$trace_tmp fi