git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git List <git@vger.kernel.org>, Sangeeta <sangunb09@gmail.com>,
	Philippe Blain <levraiphilippeblain@gmail.com>,
	Kaartic Sivaraam <kaartic.sivaraam@gmail.com>,
	Christian Couder <christian.couder@gmail.com>,
	Lars Schneider <larsxschneider@gmail.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH] t/perf: fix test_export() failure with BSD `sed`
Date: Wed, 16 Dec 2020 14:29:26 -0500	[thread overview]
Message-ID: <CAPig+cR+4Wh4Sgk6UhUML4SHqaQsvYmw_77ih+oec2YmqQJCCg@mail.gmail.com> (raw)
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:
> 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.

> 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.

  reply	other threads:[~2020-12-16 19:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16  7:39 [PATCH] t/perf: fix test_export() failure with BSD `sed` Eric Sunshine
2020-12-16 19:07 ` Junio C Hamano
2020-12-16 19:29   ` Eric Sunshine [this message]
2020-12-18  5:42     ` Jeff King
2020-12-18  6:15       ` Eric Sunshine
2020-12-18  6:24         ` Jeff King
2020-12-21  7:23     ` Eric Sunshine
2020-12-20 21:27 ` [PATCH 2/1] t/perf: avoid unnecessary test_export() recursion Eric Sunshine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPig+cR+4Wh4Sgk6UhUML4SHqaQsvYmw_77ih+oec2YmqQJCCg@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=kaartic.sivaraam@gmail.com \
    --cc=larsxschneider@gmail.com \
    --cc=levraiphilippeblain@gmail.com \
    --cc=sangunb09@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).