From db5875aa9fe056c2db3a463989091c5f70d6c8d1 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Thu, 9 Dec 2021 00:11:12 -0500 Subject: 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 Reviewed-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t1410-reflog.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t1410-reflog.sh') diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index d42f067ff8..d7ddf7612d 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -349,12 +349,12 @@ test_expect_success SHA1 'parsing reverse reflogs at BUFSIZ boundaries' ' printf "$zf%02d $zf%02d %s\t" $i $(($i+1)) "$ident" && if test $i = 75; then for j in $(test_seq 1 89); do - printf X + printf X || return 1 done else printf X fi && - printf "\n" + printf "\n" || return 1 done >.git/logs/refs/heads/reflogskip && git rev-parse reflogskip@{73} >actual && echo ${zf}03 >expect && -- cgit v1.2.3