From: Johannes Sixt <j6t@kdbg.org>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, Max Kirillov <max@max630.net>,
Carlo Arenas <carenas@gmail.com>, Jeff King <peff@peff.net>,
git@vger.kernel.org
Subject: Re: [PATCH] test-lib: check Bash version for '-x' without using shell arrays
Date: Wed, 2 Jan 2019 01:20:47 +0100 [thread overview]
Message-ID: <a82251fa-38e1-233e-50d3-3ed4850b4e11@kdbg.org> (raw)
In-Reply-To: <20190101231949.8184-1-szeder.dev@gmail.com>
Am 02.01.19 um 00:19 schrieb SZEDER Gábor:
> Alas, it has been reported that NetBSD's /bin/sh does complain about
> them:
>
> ./test-lib.sh: 327: Syntax error: Bad substitution
>
> where line 327 contains the first ${BASH_VERSINFO[0]} array access.
> 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
}
'
-- Hannes
next prev parent reply other threads:[~2019-01-02 0:24 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 [this message]
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 ` [PATCH] " Jeff King
2019-01-02 18:05 ` 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
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=a82251fa-38e1-233e-50d3-3ed4850b4e11@kdbg.org \
--to=j6t@kdbg.org \
--cc=carenas@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=max@max630.net \
--cc=peff@peff.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.
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).