From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6E5451580EB for ; Fri, 30 May 2025 08:15:06 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 32407343125 for ; Fri, 30 May 2025 08:15:06 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 379361104C1; Fri, 30 May 2025 08:14:38 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 2838C1104BE for ; Fri, 30 May 2025 08:14:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D5B9A3430A3 for ; Fri, 30 May 2025 08:14:37 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 08B4928E3 for ; Fri, 30 May 2025 08:14:35 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1748592866.a3dfcf3148506ff4f7044b0266c5a9a15cdd7663.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/phase-helpers.sh X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: a3dfcf3148506ff4f7044b0266c5a9a15cdd7663 X-VCS-Branch: master Date: Fri, 30 May 2025 08:14:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 51a733d8-abbe-4229-9fa9-f878aee4ef21 X-Archives-Hash: 044a3772e116bd0effdb1daced7efb2b commit: a3dfcf3148506ff4f7044b0266c5a9a15cdd7663 Author: Kerin Millar plushkava net> AuthorDate: Tue May 27 18:58:19 2025 +0000 Commit: Sam James gentoo org> CommitDate: Fri May 30 08:14:26 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a3dfcf31 phase-helpers.sh: use hash to gauge deb2targz availability Presently, the unpack() function uses the type builtin to determine whether deb2targz is present in PATH. type -P deb2targz >/dev/null # proves that deb2targz is in PATH deb2targz "${basename}" # deb2targz is then invoked in this manner However, using type -P in this way is questionable. While type -P does coerce bash into performing a PATH search, the manner in which deb2targz is invoked still permits for deb2targz to be a function - even an alias in the case that the expand_aliases option is enabled. Put another way, type -P is worth using where the pathname of an executable must be determined and subsequently referenced. Given that no such requirement is implied, use the hash builtin to determine whether deb2targz is available as a command. This has the advantage of pre-warming the cache that the shell employs for Command Search and Execution. Also, perform the command search before potentially performing a command substitution for ar --version. The latter operation will almost certainly be more expensive than the former. It should be noted that the revised approach incurs fewer dup2(2) calls, owing to STDERR being redirected just once. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/phase-helpers.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 7ae983ccb7..4c76d385ed 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -470,8 +470,7 @@ unpack() { # `deb2targz` installed, prefer it over `ar` for that # reason. We just make sure on AIX `deb2targz` is # installed. - if [[ $(ar --version 2>/dev/null) != "GNU ar"* ]] && \ - type -P deb2targz > /dev/null; then + if { hash deb2targz && [[ $(ar --version) != "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.