1 |
Improve the regular expressions to handle parameters consisting of |
2 |
multiple short options (such as -kj). It should be noted that the code |
3 |
is not perfect but should handle all common (valid) cases; it could e.g. |
4 |
incorrectly process a short option followed by string arg such as |
5 |
'-Wfoo.j' although having this in MAKEOPTS is extremely unlikely. |
6 |
--- |
7 |
eclass/multiprocessing.eclass | 8 ++++---- |
8 |
eclass/tests/multiprocessing_makeopts_jobs.sh | 3 +++ |
9 |
eclass/tests/multiprocessing_makeopts_loadavg.sh | 3 +++ |
10 |
3 files changed, 10 insertions(+), 4 deletions(-) |
11 |
|
12 |
diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass |
13 |
index 06e004aa1669..5a5fe9acb56a 100644 |
14 |
--- a/eclass/multiprocessing.eclass |
15 |
+++ b/eclass/multiprocessing.eclass |
16 |
@@ -67,8 +67,8 @@ makeopts_jobs() { |
17 |
# This assumes the first .* will be more greedy than the second .* |
18 |
# since POSIX doesn't specify a non-greedy match (i.e. ".*?"). |
19 |
local jobs=$(echo " $* " | sed -r -n \ |
20 |
- -e 's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \ |
21 |
- -e 's:.*[[:space:]](-j|--jobs)[[:space:]].*:999:p') |
22 |
+ -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \ |
23 |
+ -e 's:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:999:p') |
24 |
echo ${jobs:-1} |
25 |
} |
26 |
|
27 |
@@ -86,8 +86,8 @@ makeopts_loadavg() { |
28 |
# This assumes the first .* will be more greedy than the second .* |
29 |
# since POSIX doesn't specify a non-greedy match (i.e. ".*?"). |
30 |
local lavg=$(echo " $* " | sed -r -n \ |
31 |
- -e 's:.*[[:space:]](-l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p' \ |
32 |
- -e 's:.*[[:space:]](-l|--(load-average|max-load))[[:space:]].*:999:p') |
33 |
+ -e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p' \ |
34 |
+ -e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load))[[:space:]].*:999:p') |
35 |
# Default to 999 since the default is to not use a load limit. |
36 |
echo ${lavg:-999} |
37 |
} |
38 |
diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh b/eclass/tests/multiprocessing_makeopts_jobs.sh |
39 |
index 017d491156a0..a1e43c8b91d7 100755 |
40 |
--- a/eclass/tests/multiprocessing_makeopts_jobs.sh |
41 |
+++ b/eclass/tests/multiprocessing_makeopts_jobs.sh |
42 |
@@ -31,6 +31,9 @@ tests=( |
43 |
7 "-l3 --jobs 7 -w" |
44 |
4 "-j1 -j 2 --jobs 3 --jobs=4" |
45 |
8 " -j 8 " |
46 |
+ 999 "-kj" |
47 |
+ 4 "-kj4" |
48 |
+ 5 "-kj 5" |
49 |
) |
50 |
for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do |
51 |
test-makeopts_jobs "${tests[i]}" "${tests[i+1]}" |
52 |
diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh b/eclass/tests/multiprocessing_makeopts_loadavg.sh |
53 |
index 12f9d01f9fcd..276b7e70d393 100755 |
54 |
--- a/eclass/tests/multiprocessing_makeopts_loadavg.sh |
55 |
+++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh |
56 |
@@ -28,6 +28,9 @@ tests=( |
57 |
4 "-j1 -j 2 --load-average 3 --load-average=4" |
58 |
3 " --max-load=3 -x" |
59 |
8 " -l 8 " |
60 |
+ 999 "-kl" |
61 |
+ 4 "-kl4" |
62 |
+ 5 "-kl 5" |
63 |
) |
64 |
for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do |
65 |
test-makeopts_loadavg "${tests[i]}" "${tests[i+1]}" |
66 |
-- |
67 |
2.11.0 |