Re: [PATCH v3 0/2] [Outreachy][Patch v2] t3404: avoid losing exit status to pipes
From: Usman Akinyemi <hidden>
Date: 2024-10-07 09:02:02
From: Usman Akinyemi <hidden>
Date: 2024-10-07 09:02:02
On Mon, Oct 7, 2024 at 8:11 AM Eric Sunshine [off-list ref] wrote:
On Mon, Oct 7, 2024 at 4:08 AM Patrick Steinhardt [off-list ref] wrote:quoted
On Mon, Oct 07, 2024 at 07:25:44AM +0000, Usman Akinyemi wrote:quoted
test $base = $(git rev-parse HEAD^) && git show >output && grep NEVER output >actual && test_must_be_empty actual &&That makes sense. The expectation here is that `output` shouldn't contain the string "NEVER" at all. And as grep(1) would fail when it doesn't find a match the whole test would fail like this. So the below would likely be the best solution.Thanks. I was just about to respond with the same answer. As a bit of extra explanation, the &&-chaining means that every command in the chain must return "success" (status 0), but the return code of `grep` depends upon whether or not it matched any lines. In this case, it returned non-zero which caused the test to fail.
Thanks Eric and Partrick. Thanks for the explanation. I will update the patch then.