Re: [PATCH v3 11/12] t9902: fix use of `read` with `set -e`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Apr 17, 2026, 09:44 UTC
- Message-ID
- <aeIA6H2G3D2FoJPj@pks.im>
- In-Reply-To
- <xmqqbjfizlfx.fsf@gitster.g>
On Thu, Apr 16, 2026 at 01:42:26PM -0700, Junio C Hamano wrote:
Show 28 quoted lines
> SZEDER Gábor <szeder.dev@gmail.com> writes: > > > On Thu, Apr 16, 2026 at 01:19:28PM +0200, Patrick Steinhardt wrote: > >> In t9902 we're using the `read` builtin to read some values into a > >> variable. This is done by using `-d ""`, which cause us to read until > >> the end of the heredoc. There is a gotcha though: when the delimiter > >> isn't found at all, then the read builtin will return an error. > > > > The absence of the delimiter doesn't make "read" return an error, EOF > > does (that's why a "while read ..." loop works). > > Very true. So for this kind of "read", failing is the norm. > > > So AFAICT what this "read" does is equivalent to: > > > > refs='main > > maint > > next > > seen' > > > > Isn't this much easier to read!? OK, the first ref is not aligned > > with the rest... But I admit I had to look up the docs to see what > > the empty string as delimiter actually does, and even after that I had > > to add a printf '>%s<\n' "$refs" command to the test script to see > > what's exactly going on. > > Yes, whether "set -e" is used or not, not using "read" there makes a > lot more sense.
Hm, true indeed, that variant is a lot more straight-forward. Will change, thanks!
Patrick