Re: [PATCH v2 1/8] log tests: don't use "exit 1" outside a sub-shell
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 2, 2022, 01:48 UTC
- Message-ID
- <xmqqwn7apodp.fsf@gitster.g>
- In-Reply-To
- <CAPig+cQK8BRU0u0g+jAkyJaqSamYBynJ6s00_6H2beb6gXaRDA@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 9 quoted lines
>> git show -s --pretty=oneline "$r" >raw && >> - cat raw | lf_to_nul || exit 1 >> + cat raw | lf_to_nul || return 1 >> done >expect && > > Using `return 1` here is "obviously correct" since this code is not > inside a subshell. Furthermore, the exit code of the for-loop itself > is not being lost down a pipe, so `return 1` is indeed an appropriate > way to signal failure. Good.
"return 1" is obvious and safe correction. I have to wonder if test_expect_success can be taught to be smarter to intercept "exit" so we do not have to bo so careful, but that would be a much more involved change to the lower-level of test framework.