CentOS Stream 8: Use /usr/bin/which instead of bash function

A bug has been introduced to the which package in CentOS Stream 8 which
causes it to fail when used with the following bash options:

set -u
set -o pipefail

Then, when running which we see the following output:

environment: line 1: _declare: unbound variable

As found by Pierre, this seems to be caused by the implementation of
which as a bash function which references an unbound variable
(_declare). It's tracked in Fedora by
https://bugzilla.redhat.com/show_bug.cgi?id=1944877#.

This change works around the issue by using the /usr/bin/which binary.

Co-Authored-By: Pierre Riteau <pierre@stackhpc.com>

Change-Id: I468d4e0460c13791b9f01d5854ef45472528c6fe
Story: 2008795
Task: 42215
This commit is contained in:
Mark Goddard 2021-04-06 12:24:16 +01:00
parent fefba58109
commit 3084cf67ce

View File

@ -122,7 +122,7 @@ function config_init {
function is_dnf {
if [[ -e /etc/centos-release ]]; then
which dnf >/dev/null 2>&1
/usr/bin/which dnf >/dev/null 2>&1
else
return 1
fi
@ -130,7 +130,7 @@ function is_dnf {
function is_yum {
if [[ -e /etc/centos-release ]]; then
which yum >/dev/null 2>&1
/usr/bin/which yum >/dev/null 2>&1
else
return 1
fi