summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2017-02-09 13:15:13 -0500
committerMike Frysinger <vapier@gentoo.org>2017-02-09 13:16:07 -0500
commit9470312c23d126f0055f82c0e656003b3945430b (patch)
treeb7f2359d9f627ac59df262213d391b7d420b3768 /eclass
parentdev-php/PEAR-Text_Figlet: remove unused PEAR-Text_Figlet-1.0.2.ebuild. (diff)
downloadgentoo-9470312c23d126f0055f82c0e656003b3945430b.tar.gz
gentoo-9470312c23d126f0055f82c0e656003b3945430b.tar.bz2
gentoo-9470312c23d126f0055f82c0e656003b3945430b.zip
multiprocess.eclass: makeopts_{jobs,loadavg}: fix implicit handling of $MAKEOPTS #608242
We missed quoting on ${MAKEOPTS} to set it as the first arg which meant we might load invalid values into the second arg which is the "infinite" scenario.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/multiprocessing.eclass4
-rwxr-xr-xeclass/tests/multiprocessing_makeopts_jobs.sh12
-rwxr-xr-xeclass/tests/multiprocessing_makeopts_loadavg.sh11
3 files changed, 19 insertions, 8 deletions
diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index 67f7e2d65b4..73d852410b9 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -96,7 +96,7 @@ get_nproc() {
# no way to represent infinity, we return ${inf} (defaults to 999) if the user
# has -j without a number.
makeopts_jobs() {
- [[ $# -eq 0 ]] && set -- ${MAKEOPTS}
+ [[ $# -eq 0 ]] && set -- "${MAKEOPTS}"
# 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 \
@@ -117,7 +117,7 @@ makeopts_jobs() {
# If no limit is specified or --load-average is used without a number, ${inf}
# (defaults to 999) is returned.
makeopts_loadavg() {
- [[ $# -eq 0 ]] && set -- ${MAKEOPTS}
+ [[ $# -eq 0 ]] && set -- "${MAKEOPTS}"
# 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 \
diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh b/eclass/tests/multiprocessing_makeopts_jobs.sh
index ef477277ab3..cc4f91b6943 100755
--- a/eclass/tests/multiprocessing_makeopts_jobs.sh
+++ b/eclass/tests/multiprocessing_makeopts_jobs.sh
@@ -10,14 +10,20 @@ inherit multiprocessing
test-makeopts_jobs() {
local exp=$1; shift
tbegin "makeopts_jobs($1${2+; inf=${2}}) == ${exp}"
- local act=$(makeopts_jobs "$@")
- [[ ${act} == "${exp}" ]]
- tend $? "Got back: ${act}"
+ local indirect=$(MAKEOPTS="$*" makeopts_jobs)
+ local direct=$(makeopts_jobs "$@")
+ if [[ "${direct}" != "${indirect}" ]] ; then
+ tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != '${direct}'"
+ else
+ [[ ${direct} == "${exp}" ]]
+ tend $? "Got back: ${act}"
+ fi
}
tests=(
999 "-j"
999 "--jobs"
+ 999 "-j -l9"
1 ""
1 "-l9 -w"
1 "-l9 -w-j4"
diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh b/eclass/tests/multiprocessing_makeopts_loadavg.sh
index 6b976beb1ae..ffa679d13e2 100755
--- a/eclass/tests/multiprocessing_makeopts_loadavg.sh
+++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh
@@ -10,9 +10,14 @@ inherit multiprocessing
test-makeopts_loadavg() {
local exp=$1; shift
tbegin "makeopts_loadavg($1${2+; inf=${2}}) == ${exp}"
- local act=$(makeopts_loadavg "$@")
- [[ ${act} == "${exp}" ]]
- tend $? "Got back: ${act}"
+ local indirect=$(MAKEOPTS="$*" makeopts_loadavg)
+ local direct=$(makeopts_loadavg "$@")
+ if [[ "${direct}" != "${indirect}" ]] ; then
+ tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != '${direct}'"
+ else
+ [[ ${direct} == "${exp}" ]]
+ tend $? "Got back: ${act}"
+ fi
}
tests=(