commit:     21bd1ccf4a4a4f84928bb24e9832e2b4ad4c8d9a
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu Jun 26 04:43:50 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 28 02:30:17 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=21bd1ccf

phase-helpers.sh: check for GNU ar in a quieter way

Presently, the unpack() function employs the combination of a
conditional expression and a command substitution to test whether the
implementation of ar(1) is provided by GNU. However, the captured output
of ar --version will be shown in its entirety, provided that the
following two conditions hold true.

- the xtrace shell option is enabled
- BASH_XTRACEFD is set to something other than 2

Specifically, the captured output will be written to the file descriptor
that is referenced by 'BASH_XTRACEFD', which could be somewhat grating.
Address this issue by instead using grep(1) to match against the output
stream of ar(1).

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/phase-helpers.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 918aaab75c..94b922d45b 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -466,7 +466,7 @@ unpack() {
                                # `deb2targz` installed, prefer it over `ar` 
for that
                                # reason.  We just make sure on AIX `deb2targz` 
is
                                # installed.
-                               if { hash deb2targz && [[ $(ar --version) != 
"GNU ar"* ]]; } 2>/dev/null; then
+                               if { hash deb2targz && ! ar --version | grep -q 
'^GNU ar'; } 2>/dev/null; then
                                        # deb2targz always extracts into the 
same directory as
                                        # the source file, so create a symlink 
in the current
                                        # working directory if necessary.

Reply via email to