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, 03:24 UTC
- Message-ID
- <xmqqbkompjw6.fsf@gitster.g>
- In-Reply-To
- <CAPig+cQK8BRU0u0g+jAkyJaqSamYBynJ6s00_6H2beb6gXaRDA@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 9 quoted lines
>> for r in $revs >> do >> 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.
While it is safe and correct, I wonder if test_expect_success can be made a bit smarter by somehow capturing what happens inside its body. We of course cannot just wrap everything inside a subshell, as we do want to allow the test body to affect the shell environment it is running in with its side effects.