t: simplify loop exit-code status variables
Since shell loops may drop the exit code of failed commands inside the loop, some tests try to keep track of the status by setting a variable. This can end up cumbersome and hard to read; it is much simpler to just exit directly from the loop using "return 1" (since each case is either in a helper function or inside a test snippet). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e6821d09e4
commit
c6587bddc4
@ -18,22 +18,16 @@ test_expect_success setup '
|
||||
|
||||
echo file >expected &&
|
||||
mkdir sub &&
|
||||
bad= &&
|
||||
for n in 0 1 2 3 4 5
|
||||
do
|
||||
for m in 0 1 2 3 4 5 6 7 8 9
|
||||
do
|
||||
num=00$n$m &&
|
||||
>sub/file-$num &&
|
||||
echo file-$num >>expected || {
|
||||
bad=t
|
||||
break
|
||||
}
|
||||
done && test -z "$bad" || {
|
||||
bad=t
|
||||
break
|
||||
}
|
||||
done && test -z "$bad" &&
|
||||
echo file-$num >>expected ||
|
||||
return 1
|
||||
done
|
||||
done &&
|
||||
git add . &&
|
||||
git commit -m "add a bunch of files" &&
|
||||
|
||||
|
Reference in New Issue
Block a user