t0000-t3999: detect and signal failure within loop

Failures within `for` and `while` loops can go unnoticed if not detected
and signaled manually since the loop itself does not abort when a
contained command fails, nor will a failure necessarily be detected when
the loop finishes since the loop returns the exit code of the last
command it ran on the final iteration, which may not be the command
which failed. Therefore, detect and signal failures manually within
loops using the idiom `|| return 1` (or `|| exit 1` within subshells).

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Eric Sunshine
2021-12-09 00:11:12 -05:00
committed by Junio C Hamano
parent efe26b9ee0
commit db5875aa9f
31 changed files with 55 additions and 55 deletions

View File

@ -116,7 +116,7 @@ test_expect_success 'cache-tree does not ignore dir that has i-t-a entries' '
mkdir 2 &&
for f in 1 2/1 2/2 3
do
echo "$f" >"$f"
echo "$f" >"$f" || return 1
done &&
git add 1 2/2 3 &&
git add -N 2/1 &&