git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Sixt <j6t@kdbg.org>
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Max Kirillov" <max@max630.net>,
	"Carlo Arenas" <carenas@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] test-lib: check Bash version for '-x' without using shell arrays
Date: Wed, 2 Jan 2019 23:52:00 -0500	[thread overview]
Message-ID: <20190103045200.GB20047@sigill.intra.peff.net> (raw)
In-Reply-To: <a82251fa-38e1-233e-50d3-3ed4850b4e11@kdbg.org>

On Wed, Jan 02, 2019 at 01:20:47AM +0100, Johannes Sixt wrote:

> > diff --git a/t/test-lib.sh b/t/test-lib.sh
> > index 0f1faa24b2..f47a191e3b 100644
> > --- a/t/test-lib.sh
> > +++ b/t/test-lib.sh
> > @@ -324,9 +324,12 @@ do
> >   		# isn't executed with a suitable Bash version.
> >   		if test -z "$test_untraceable" || {
> >   		     test -n "$BASH_VERSION" && {
> > -		       test ${BASH_VERSINFO[0]} -gt 4 || {
> > -			 test ${BASH_VERSINFO[0]} -eq 4 &&
> > -			 test ${BASH_VERSINFO[1]} -ge 1
> > +		       bash_major=${BASH_VERSION%%.*}
> > +		       bash_minor=${BASH_VERSION#*.}
> > +		       bash_minor=${bash_minor%%.*}
> > +		       test $bash_major -gt 4 || {
> > +			 test $bash_major -eq 4 &&
> > +			 test $bash_minor -ge 1
> >   		       }
> >   		     }
> >   		   }
> > 
> 
> Would it perhaps be simpler to just hide the syntax behind eval? Like
> 
>  		if test -z "$test_untraceable" || {
>  		     test -n "$BASH_VERSION" && eval '
> 		       test ${BASH_VERSINFO[0]} -gt 4 || {
> 			 test ${BASH_VERSINFO[0]} -eq 4 &&
> 			 test ${BASH_VERSINFO[1]} -ge 1
> 		       }
>  		     '

That was my first thought, too. :)

The parsing here is simple enough that I'd be fine either with the
original patch, or an eval-based version (and otherwise, the goal and
description seem quite good to me).

-Peff

  parent reply	other threads:[~2019-01-03  4:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01 23:19 [PATCH] test-lib: check Bash version for '-x' without using shell arrays SZEDER Gábor
2019-01-02  0:20 ` Johannes Sixt
2019-01-02 16:46   ` Junio C Hamano
2019-01-03 11:43     ` [PATCH v2] " SZEDER Gábor
2019-01-03 20:29       ` Junio C Hamano
2019-01-04  9:30         ` SZEDER Gábor
2019-01-04 11:25           ` Junio C Hamano
2019-01-04 12:38             ` SZEDER Gábor
2019-01-04 18:42               ` Carlo Arenas
2019-01-04 20:04                 ` Junio C Hamano
2019-01-03  4:52   ` Jeff King [this message]
2019-01-02 18:05 ` [PATCH] " Eric Sunshine
2019-01-02 18:31   ` Carlo Arenas
2019-01-03 11:36 ` SZEDER Gábor

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=20190103045200.GB20047@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=max@max630.net \
    --cc=szeder.dev@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).