diff options
author | Michał Górny <mgorny@gentoo.org> | 2016-12-13 09:57:46 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2016-12-18 14:45:43 +0100 |
commit | 639d76a02d2965f426944f7fa6d0259a99a613f9 (patch) | |
tree | 965dd1e87e9e1c4a5682236de0045a1b47ec743e /eclass | |
parent | net-misc/aria2: Bump to 1.30.0 (diff) | |
download | gentoo-639d76a02d2965f426944f7fa6d0259a99a613f9.tar.gz gentoo-639d76a02d2965f426944f7fa6d0259a99a613f9.tar.bz2 gentoo-639d76a02d2965f426944f7fa6d0259a99a613f9.zip |
multiprocessing.eclass: Fix handling multiple short options (e.g. -kj)
Improve the regular expressions to handle parameters consisting of
multiple short options (such as -kj). It should be noted that the code
is not perfect but should handle all common (valid) cases; it could e.g.
incorrectly process a short option followed by string arg such as
'-Wfoo.j' although having this in MAKEOPTS is extremely unlikely.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/multiprocessing.eclass | 8 | ||||
-rwxr-xr-x | eclass/tests/multiprocessing_makeopts_jobs.sh | 3 | ||||
-rwxr-xr-x | eclass/tests/multiprocessing_makeopts_loadavg.sh | 3 |
3 files changed, 10 insertions, 4 deletions
diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass index 06e004aa1669..5a5fe9acb56a 100644 --- a/eclass/multiprocessing.eclass +++ b/eclass/multiprocessing.eclass @@ -67,8 +67,8 @@ 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 " $* " | sed -r -n \ - -e 's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \ - -e 's:.*[[:space:]](-j|--jobs)[[:space:]].*:999:p') + -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \ + -e 's:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:999:p') echo ${jobs:-1} } @@ -86,8 +86,8 @@ makeopts_loadavg() { # This assumes the first .* will be more greedy than the second .* # since POSIX doesn't specify a non-greedy match (i.e. ".*?"). local lavg=$(echo " $* " | sed -r -n \ - -e 's:.*[[:space:]](-l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p' \ - -e 's:.*[[:space:]](-l|--(load-average|max-load))[[:space:]].*:999:p') + -e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p' \ + -e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load))[[:space:]].*:999:p') # Default to 999 since the default is to not use a load limit. echo ${lavg:-999} } diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh b/eclass/tests/multiprocessing_makeopts_jobs.sh index 017d491156a0..a1e43c8b91d7 100755 --- a/eclass/tests/multiprocessing_makeopts_jobs.sh +++ b/eclass/tests/multiprocessing_makeopts_jobs.sh @@ -31,6 +31,9 @@ tests=( 7 "-l3 --jobs 7 -w" 4 "-j1 -j 2 --jobs 3 --jobs=4" 8 " -j 8 " + 999 "-kj" + 4 "-kj4" + 5 "-kj 5" ) for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do test-makeopts_jobs "${tests[i]}" "${tests[i+1]}" diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh b/eclass/tests/multiprocessing_makeopts_loadavg.sh index 12f9d01f9fcd..276b7e70d393 100755 --- a/eclass/tests/multiprocessing_makeopts_loadavg.sh +++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh @@ -28,6 +28,9 @@ tests=( 4 "-j1 -j 2 --load-average 3 --load-average=4" 3 " --max-load=3 -x" 8 " -l 8 " + 999 "-kl" + 4 "-kl4" + 5 "-kl 5" ) for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do test-makeopts_loadavg "${tests[i]}" "${tests[i+1]}" |