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 4072A158074 for ; Fri, 20 Jun 2025 05:45:58 +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) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 2A475341980 for ; Fri, 20 Jun 2025 05:45:58 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id D44BB1104F7; Fri, 20 Jun 2025 05:45:45 +0000 (UTC) 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) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id C2F4D1104F7 for ; Fri, 20 Jun 2025 05:45:45 +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) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 581F4341051 for ; Fri, 20 Jun 2025 05:45:45 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EA87B29FD for ; Fri, 20 Jun 2025 05:45:42 +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: <1750398337.515b0ce595f98c8f7a31ebeaff5123ec9e4568a7.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/emerge-webrsync X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 515b0ce595f98c8f7a31ebeaff5123ec9e4568a7 X-VCS-Branch: master Date: Fri, 20 Jun 2025 05:45:42 +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: 7f4c8e91-6b10-4766-b3b5-43a05ad7bb60 X-Archives-Hash: 881643b77424fb46a97216ee368ca34d commit: 515b0ce595f98c8f7a31ebeaff5123ec9e4568a7 Author: Kerin Millar plushkava net> AuthorDate: Fri Jun 20 01:17:51 2025 +0000 Commit: Sam James gentoo org> CommitDate: Fri Jun 20 05:45:37 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=515b0ce5 emerge-webrsync: use hash to gauge utility availability Presently, the type builtin is used to check for the availability of the following utilities. - bzcat(1) - gemato - md5(1) - md5sum(1) - tarsync(1) - xzcat(1) - zcat(1) To do so is questionable. While type -P does coerce bash into performing a PATH search, the manner in which all of these utilities is invoked still permits for them to be defined as functions. Instead, use the hash builtin. This has the advantage of pre-warming - and subsequently consulting - the cache that the shell employs for Command Search and Execution. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/emerge-webrsync | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 802a756f96..bdbec10c92 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -135,7 +135,7 @@ handle_pgp_setup() { die "PORTAGE_GPG_DIR is unset or empty (the webrsync-gpg feature requires that it be set)" fi WEBRSYNC_VERIFY_SIGNATURE=2 - elif ! type -P gemato > /dev/null; then + elif ! hash gemato 2>/dev/null; then # Fall back to conventional verification with gpg(1). ewarn "app-portage/gemato does not appear to be installed. Falling back to gpg." WEBRSYNC_VERIFY_SIGNATURE=2 @@ -247,11 +247,11 @@ check_file_digest() { einfo "Checking digest ..." - if type -P md5sum > /dev/null; then + if hash md5sum 2>/dev/null; then md5sum_output=$(md5sum "${file}") digest_content=$(< "${digest}") [[ "${md5sum_output%%[[:space:]]*}" = "${digest_content%%[[:space:]]*}" ]] - elif type -P md5 > /dev/null; then + elif hash md5 2>/dev/null; then [[ "$(md5 -q "${file}")" == "$(cut -d ' ' -f 1 "${digest}")" ]] else die "cannot check digest: no suitable md5/md5sum binaries found" @@ -401,7 +401,7 @@ sync_local() { ownership=$(stat -c '%U:%G' "${repo_location}") fi || exit - if type -P tarsync > /dev/null ; then + if hash tarsync 2>/dev/null; then tarsync_opts=( -s 1 -e /distfiles -e /packages -e /local ) if chown "${ownership}" "${repo_location}" 2>/dev/null; then tarsync_opts+=( -o "${ownership%:*}" -g "${ownership#*:}" ) @@ -464,10 +464,10 @@ do_snapshot() { suffix_by=([xzcat]=xz [bzcat]=bz2 [zcat]=gz) for file in xzcat bzcat zcat; do - if type -P "${file}"; then + if hash "${file}" 2>/dev/null; then tarballs+=( {"$repo_name","portage"}-"${date}.tar.${suffix_by[$file]}" ) fi - done >/dev/null + done if (( ! ${#tarballs[@]} )); then die "unable to locate any decompressors (xzcat, bzcat or zcat)"