git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Armin Kunaschik <megabreit@googlemail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: t4204-patch-id failures
Date: Tue, 24 May 2016 00:56:18 +0200	[thread overview]
Message-ID: <CALR6jEgjcAGjLBbHuB+sG24Xwp9AH1i8SbtSdQoLyFcKmwAAcA@mail.gmail.com> (raw)
In-Reply-To: <xmqqbn3w76rn.fsf@gitster.mtv.corp.google.com>

On Tue, May 24, 2016 at 12:23 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:

> Having said all that, this illustrates the root cause of different
> behaviours better, but it is harder to reason about than simply
> changing the variable name used in this shell function.  POSIX reads
> a bit fuzzy to me around here:
>
>     ... each command of a multi-command pipeline is in a subshell
>     environment; as an extension, however, any or all commands in a
>     pipeline may be executed in the current environment. All other
>     commands shall be executed in the current shell environment.
>
> That essentially says nothing useful; it does not guarantee that
> each command on a pipeline runs in its own subshell environment, and
> a portable script must be prepared to see some of them run in the
> current shell environment.

Writing portable shell scripts sometimes is quite a mess :-)

> So let's do this instead:
>
> -- >8 --
> Subject: t4204: do not let $name variable clobbered
>
> test_patch_id_file_order shell function uses $name variable to hold
> one filename, and calls another shell function calc_patch_id as a
> downstream of one pipeline.  The called function, however, also uses
> the same $name variable.  With a shell implementation that runs the
> callee in the current shell environment, the caller's $name would
> be clobbered by the callee's use of the same variable.
>
> This hasn't been an issue with dash and bash.  ksh93 reveals the
> breakage in the test script.

Maybe add ksh88 too, just to be "feature" complete.

> Fix it by using a distinct variable name in the callee.

Agreed.

> Reported-by: Armin Kunaschik <megabreit@googlemail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

      reply	other threads:[~2016-05-23 22:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23 16:30 t4204-patch-id failures Armin Kunaschik
2016-05-23 20:47 ` Junio C Hamano
2016-05-23 22:23   ` Junio C Hamano
2016-05-23 22:56     ` Armin Kunaschik [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CALR6jEgjcAGjLBbHuB+sG24Xwp9AH1i8SbtSdQoLyFcKmwAAcA@mail.gmail.com \
    --to=megabreit@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).