commit:     c53f2d7aee038cba983c312a12738a58e6eed5a1
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Jun  6 14:01:45 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  6 22:02:16 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c53f2d7a

isolated-functions.sh: correctly handle bundled -j options in MAKEOPTS

Recently, the extended regular expression that is used to parse -j and
--jobs out of MAKEOPTS was adjusted so as to handle some edge cases.
Yet, I inadvertently introduced a regression by employing [^j] to match
short options preceding a bundled -j option. Of course, it should be
[A-Ia-iK-Zk-z] and acted upon with the C/POSIX collation in effect. The
resulting regular expression is as follows.

.*[[:space:]]
(
        # short options other than -j, if any, leading up to -j,
        # optionally followed by whitespace
        -[A-Ia-iK-Zk-z]*j[[:space:]]*
        |
        # --jobs followed by either = or whitespace
        --jobs(=|[[:space:]]+)
)
([0-9]+)    # the job count ...
[[:space:]] # which must not have any trailing garbage

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

 bin/isolated-functions.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 7760ba717f..b35fc7e926 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -494,9 +494,9 @@ if [[ -z ${XARGS} ]] ; then
 fi
 
 ___makeopts_jobs() {
-       local ere jobs
+       local LC_ALL LC_COLLATE=C ere jobs
 
-       
ere='.*[[:space:]](-[^j]*j[[:space:]]*|--jobs(=|[[:space:]]+))([0-9]+)[[:space:]]'
+       
ere='.*[[:space:]](-[A-Ia-iK-Zk-z]*j[[:space:]]*|--jobs(=|[[:space:]]+))([0-9]+)[[:space:]]'
 
        if [[ " ${MAKEOPTS} " =~ $ere ]]; then
                jobs=$(( 10#${BASH_REMATCH[3]} ))

Reply via email to