git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carlo Arenas <carenas@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, congdanhqx@gmail.com,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] t/test_lib: avoid naked bash arrays in file_lineno
Date: Thu, 7 May 2020 10:33:15 -0700	[thread overview]
Message-ID: <CAPUEspiPduAoxL4L-p97A-DR46EBp1HcpFMLgd4YfJbNv653xQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqr1vv4wzo.fsf@gitster.c.googlers.com>

On Thu, May 7, 2020 at 7:53 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:
>
> > 662f9cf154 (tests: when run in Bash, annotate test failures with file
> > name/line number, 2020-04-11), introduces a way to report the location
> > (file:lineno) of a failed test case by traversing the bash callstack.
> >
> > The implementation requires bash and is therefore protected by a guard
> > but NetBSD sh will still have to parse the function and therefore will
> > result in:
> >
> >   ** t0000-basic.sh ***
> >   ./test-lib.sh: 681: Syntax error: Bad substitution
> >
> > Enclose the bash specific code inside an eval to avoid parsing errors
> > and while at it, simplify the logic so that instead of traversing the
> > callstack just pop the two topmost entries that are required.
> >
> > Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>
> Is the rewritten bash-snippet in the evaled text what Dscho
> suggested us to use, or is it totally yours?

It is all mine, but Dscho's detailed description of the implementation it
is replacing allowed me to validate its correctness (under the documented
use cases)

my hope was that Dscho's and Danh would quickly agree as it is simpler
and faster, as well as providing some more description of its operation in
the commit message for future reviewers.

> I know Dscho helped to
> shoot down some "simpler" reimplementations you came up with,
> pointing out how they were broken, but it is unclear how we ended up
> with this version.

I made the wrong assumptions while focusing on translating the code
to posix sh and ended up with a broken version.

Another reason why I did the "while at it" was to avoid someone else
having the same problem by simplifying it and making sure that uncommon
syntax (like ${1+$1..}, or the use of $LINENO which would never apply
to our code)
weren't needed.

> I wish you didn't do the "while at it" rewrite in the same patch.
> If it were only "put bash-only stuff in an evaled string", it would
> have been a lot more comfortable applying it and merging quickly
> down, as it would be clear that we won't be breaking bash codepath
> and we'd be helping other shells.  With the "while at it", you made
> it quite unclear.

fair enough, and considering that "fixing other shell" has higher priority
will send a v2 to do so.

will do any "simplification" on a follow up and try to monitor these issues
early

Carlo

  reply	other threads:[~2020-05-07 17:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07  5:51 [PATCH] t/test_lib: avoid naked bash arrays in file_lineno Carlo Marcelo Arenas Belón
2020-05-07 14:53 ` Junio C Hamano
2020-05-07 17:33   ` Carlo Arenas [this message]
2020-05-07 17:57 ` Carlo Marcelo Arenas Belón
2020-05-08 23:53   ` Johannes Schindelin
2020-05-07 19:52 ` Johannes Schindelin
2020-05-08  0:58   ` Carlo Marcelo Arenas Belón
2020-05-08  1:17     ` Junio C Hamano

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=CAPUEspiPduAoxL4L-p97A-DR46EBp1HcpFMLgd4YfJbNv653xQ@mail.gmail.com \
    --to=carenas@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=congdanhqx@gmail.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.
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).