git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: Elia Pinto <gitter.spiros@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] test-lib.sh: Use GLIBC_TUNABLES instead of MALLOC_CHECK_ on glibc >= 2.34
Date: Mon, 28 Feb 2022 18:27:14 -0800	[thread overview]
Message-ID: <xmqqtuciwgot.fsf@gitster.g> (raw)
In-Reply-To: <Yh12FNTGuJkRlqBE@camp.crustytoothpaste.net> (brian m. carlson's message of "Tue, 1 Mar 2022 01:25:40 +0000")

"brian m. carlson" <sandals@crustytoothpaste.net> writes:

>> > +	if type -p getconf >/dev/null 2>&1; then
>> > +		_GLIBC_VERSION="$(getconf GNU_LIBC_VERSION 2>/dev/null | awk '{ print $2 }')"
>> > +		if [ -n "$_GLIBC_VERSION" -a $(expr "$_GLIBC_VERSION" \>= "2.34") ]; then
>> > +			_HAVE_GLIBC_234="yes"
>> > +		fi
>> > +	fi
>> 
>> Style.  We prefer "test ..." over "[ ... ]" and more importantly we
>> don't use "test X -a Y".
>> 
>> Do we absolutely need "test -p getconf" with an extra indentation?
>> I suspect we don't.
>
> getconf is specified by POSIX, but that doesn't mean it's in the default
> install or in PATH on all systems.  However, we should write "command -v
> getconf" instead if we need to check, since that's the POSIX way to
> write it, and "type" is not guaranteed to be present on all systems.

My point was that the code relies on having getconf on PATH anyway,
so it is sufficient to attempt running getconf and using its output
after checking it begins with "glibc".  Missing getconf or getconf
that is different from what we expect it to be would be rejected by
the same code, without needing the above nested if .. if .. fi .. fi

      reply	other threads:[~2022-03-01  2:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28 16:08 [PATCH] test-lib.sh: Use GLIBC_TUNABLES instead of MALLOC_CHECK_ on glibc >= 2.34 Elia Pinto
2022-02-28 19:13 ` Junio C Hamano
2022-03-01  1:25   ` brian m. carlson
2022-03-01  2:27     ` Junio C Hamano [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

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

  git send-email \
    --in-reply-to=xmqqtuciwgot.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitter.spiros@gmail.com \
    --cc=sandals@crustytoothpaste.net \
    /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).