]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t3920: don't ignore errors of more than one command with `|| true`
authorJohannes Sixt <j6t@kdbg.org>
Mon, 21 Nov 2022 17:58:13 +0000 (18:58 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Dec 2022 01:02:34 +0000 (10:02 +0900)
It is customary to write `A || true` to ignore a potential error exit of
command A. But when we have a sequence `A && B && C || true && D`, then
a failure of any of A, B, or C skips to D right away. This is not
intended here. Turn the command whose failure is to be ignored into a
compound command to ensure it is the only one that is allowed to fail.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3920-crlf-messages.sh

index 4c661d4d54a779f8bc056c62e5d9e864401420c7..a58522c163d204b168a932e895f29a414426277f 100755 (executable)
@@ -12,7 +12,7 @@ create_crlf_ref () {
        cat >.crlf-orig-$branch.txt &&
        cat .crlf-orig-$branch.txt | append_cr >.crlf-message-$branch.txt &&
        grep 'Subject' .crlf-orig-$branch.txt | tr '\n' ' ' | sed 's/[ ]*$//' | tr -d '\n' >.crlf-subject-$branch.txt &&
-       grep 'Body' .crlf-message-$branch.txt >.crlf-body-$branch.txt || true &&
+       { grep 'Body' .crlf-message-$branch.txt >.crlf-body-$branch.txt || true; } &&
        LIB_CRLF_BRANCHES="${LIB_CRLF_BRANCHES} ${branch}" &&
        test_tick &&
        hash=$(git commit-tree HEAD^{tree} -p HEAD -F .crlf-message-${branch}.txt) &&