t4301: fix broken &&-chains and add missing loop termination
commit87ed97167a1b1bce41e0380ec6a9507876015e89
authorEric Sunshine <sunshine@sunshineco.com>
Sun, 28 Aug 2022 05:17:58 +0000 (28 05:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Aug 2022 16:28:31 +0000 (29 09:28 -0700)
tree78045b80852727abc26639cc3ec920ddd1a1d373
parentbcf325ae775c4e5dab39cd30b16564b7b3d66b80
t4301: fix broken &&-chains and add missing loop termination

Fix &&-chain breaks in a couple tests which went unnoticed due to blind
spots in the &&-chain linters. In particular, the "magic exit code 117"
&&-chain checker built into test-lib.sh only recognizes broken &&-chains
at the top-level; it does not work within `{...}` groups, `(...)`
subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. Furthermore,
`chainlint.sed`, which detects broken &&-chains only in `(...)`
subshells, missed these cases (which are in subshells) because it
(surprisingly) neglects to check for intact &&-chain on single-line
`for` loops.

While at it, explicitly signal failure of commands within the `for`
loops (which might arise due to the filesystem being full or "inode"
exhaustion). This is important since 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.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4301-merge-tree-write-tree.sh