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 E061D15807A for ; Thu, 05 Jun 2025 11:22:23 +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 CBDA934312A for ; Thu, 05 Jun 2025 11:22:23 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 9622F11047E; Thu, 05 Jun 2025 11:22:15 +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 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 8FFC211047E for ; Thu, 05 Jun 2025 11:22:15 +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) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 48E76343102 for ; Thu, 05 Jun 2025 11:22:15 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 77B822900 for ; Thu, 05 Jun 2025 11:22:13 +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: <1749122524.91ebb13ace13b9a0fc3d324fd8834e768bbc40d0.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/isolated-functions.sh X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 91ebb13ace13b9a0fc3d324fd8834e768bbc40d0 X-VCS-Branch: master Date: Thu, 05 Jun 2025 11:22:13 +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: 63c45f2a-7606-47b2-a86f-1ccc6e35bf6e X-Archives-Hash: 38a4a2b883302a54053494ab3f6f6fbf commit: 91ebb13ace13b9a0fc3d324fd8834e768bbc40d0 Author: Kerin Millar plushkava net> AuthorDate: Thu Aug 11 04:12:05 2022 +0000 Commit: Sam James gentoo org> CommitDate: Thu Jun 5 11:22:04 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=91ebb13a isolated-functions.sh: use a conditional expression to parse MAKEOPTS Not only is -r a non-standard sed(1) option (unlike -E), but the conditional expression of bash supports extended regular expression matching. Use it and avoid three subshells into the bargain. Where the external utilities are executed, neither create a subshell nor redirect STDERR more than once. Use the printf builtin instead of echo. Quote the expansion of 'jobs' so as to eliminate an SC2068 warning. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/isolated-functions.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 644795f811..aab0f667ba 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -494,19 +494,20 @@ if [[ -z ${XARGS} ]] ; then fi ___makeopts_jobs() { + local jobs + # Copied from multiprocessing.eclass:makeopts_jobs # This assumes the first .* will be more greedy than the second .* # since POSIX doesn't specify a non-greedy match (i.e. ".*?"). - local jobs=$(echo " ${MAKEOPTS} " | sed -r -n \ - -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' || die) - - # Fallbacks for if MAKEOPTS parsing failed - [[ -n ${jobs} ]] || \ - jobs=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \ - jobs=$(sysctl -n hw.ncpu 2>/dev/null) || \ + if [[ " ${MAKEOPTS} " =~ .*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).* ]]; then + jobs=${BASH_REMATCH[2]} + elif jobs=$({ getconf _NPROCESSORS_ONLN || sysctl -n hw.ncpu; } 2>/dev/null); then + : + else jobs=1 + fi - echo ${jobs} + printf '%s\n' "${jobs}" } # Run ${XARGS} in parallel for detected number of CPUs, if supported.