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 20FC815807A for ; Thu, 05 Jun 2025 11:22:22 +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 040B0343144 for ; Thu, 05 Jun 2025 11:22:22 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 7FD5111047D; 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 7A2CE11047D 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 31791343100 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 912212903 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.91f7b072c851e69abefafed1b43902772fb4058c.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: 91f7b072c851e69abefafed1b43902772fb4058c 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: 0412aaaf-eb24-4346-9546-736ea1495d2a X-Archives-Hash: 7d249dadd4d14bd2ac5549307190a855 commit: 91f7b072c851e69abefafed1b43902772fb4058c Author: Kerin Millar plushkava net> AuthorDate: Sun Jun 1 15:58:10 2025 +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=91f7b072 isolated-functions.sh: improve the ERE detecting -j in MAKEOPTS In many ways, to parse -j and/or --jobs from MAKEOPTS is a fool's errand. There is no way of going about it correctly, short of implementing an option parser that behaves precisely as does that of make(1) itself. Still, the regular expression that is presently employed can be made less worse, so to speak. This commit revises it to be as follows. .*[[:space:]] ( # short options other than -j, if any, leading up to -j, # optionally followed by whitespace -[^j]*j[[:space:]]* | # --jobs followed by either = or whitespace --jobs(=|[[:space:]]+) ) ([0-9]+) # the job count ... [[:space:]] # which must not have any trailing garbage The following table shows the increased strictness of this expression. SUBSTRING BEFORE AFTER --jobs= 4 Valid Invalid --jobs 4x Valid Invalid -j4x Valid Invalid -jj4 Valid Invalid Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/isolated-functions.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index aab0f667ba..fefc0d2ab7 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -496,11 +496,8 @@ 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. ".*?"). - if [[ " ${MAKEOPTS} " =~ .*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).* ]]; then - jobs=${BASH_REMATCH[2]} + if [[ " ${MAKEOPTS} " =~ .*[[:space:]](-[^j]*j[[:space:]]*|--jobs(=|[[:space:]]+))([0-9]+)[[:space:]] ]]; then + jobs=${BASH_REMATCH[3]} elif jobs=$({ getconf _NPROCESSORS_ONLN || sysctl -n hw.ncpu; } 2>/dev/null); then : else