Re: [PATCH] t/perf: fix test_export() failure with BSD `sed`
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Dec 16, 2020, 19:29 UTC
- Message-ID
- <CAPig+cR+4Wh4Sgk6UhUML4SHqaQsvYmw_77ih+oec2YmqQJCCg@mail.gmail.com>
- In-Reply-To
- <xmqq5z514lj5.fsf@gitster.c.googlers.com>
On Wed, Dec 16, 2020 at 2:07 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > test_export () {
> > [ $# != 0 ] || return 0
> > - test_export_="$test_export_\\|$1"
> > + test_export_="$test_export_ $1"
> > shift
> > test_export "$@"
> > }
>
> This "recursion to consume $@ one by one, instead of looping" caught
> my eyes a bit, but the bug being fixed is not caused by it, so it is
> fine to let it pass.The unusual recursion caught my eye as well.
Show 9 quoted lines
> Given that the arguments to test_export are
> supposed to be all variable names (i.e. no funny characters anywhere
> in it), I think it could just be
>
> test_export () {
> test_export_="$*"
> }
>
> though.That's almost good enough, but test_export() needs to accumulate the to-be-exported variables across multiple calls, so the non-recursive definition would likely be:
test_export () {
test_export_="$test_export_ $*"
}which would make a nice cleanup atop this portability-fix patch.
> Oh, does anybody need to clear test_export_ to an empty string (or > unset it), by the way?
Perhaps a test_unexport() might be handy in the distant future, but presently there is only a single call to test_export() in the entire suite, so it's probably not worth worrying about now.