1 |
commit: f7a0474438f6571cf105fe7aa8bf3831f8bddb09 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Sep 6 13:31:56 2017 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Sep 6 13:31:56 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f7a04744 |
7 |
|
8 |
eapi7-ver.eclass: Shift component indexes to account for possible s0 |
9 |
|
10 |
eclass/eapi7-ver.eclass | 13 +++++++++---- |
11 |
1 file changed, 9 insertions(+), 4 deletions(-) |
12 |
|
13 |
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass |
14 |
index 2485c45637b..e9f2c453514 100644 |
15 |
--- a/eclass/eapi7-ver.eclass |
16 |
+++ b/eclass/eapi7-ver.eclass |
17 |
@@ -34,12 +34,17 @@ _version_parse_range() { |
18 |
[[ ${start} -gt 0 ]] && [[ -z ${end} || ${start} -le ${end} ]] || die |
19 |
} |
20 |
|
21 |
+# RETURNS: |
22 |
+# comp=( s0 c1 s1 c2 s2... ) |
23 |
+# where s - separator, c - component |
24 |
_version_split() { |
25 |
local v=$1 LC_ALL=C |
26 |
|
27 |
+ comp=("") |
28 |
+ |
29 |
# get first component |
30 |
[[ ${v} =~ ^([A-Za-z]*|[0-9]*) ]] || die |
31 |
- comp=("${BASH_REMATCH[1]}") |
32 |
+ comp+=("${BASH_REMATCH[1]}") |
33 |
v=${v:${#BASH_REMATCH[0]}} |
34 |
|
35 |
# get remaining separators and components |
36 |
@@ -59,9 +64,9 @@ version_cut() { |
37 |
|
38 |
local IFS= |
39 |
if [[ ${end} ]]; then |
40 |
- echo "${comp[*]:(start-1)*2:(end-start)*2+1}" |
41 |
+ echo "${comp[*]:(start-1)*2+1:(end-start)*2+1}" |
42 |
else |
43 |
- echo "${comp[*]:(start-1)*2}" |
44 |
+ echo "${comp[*]:(start-1)*2+1}" |
45 |
fi |
46 |
} |
47 |
|
48 |
@@ -74,7 +79,7 @@ version_rs() { |
49 |
while [[ $# -ge 2 ]]; do |
50 |
_version_parse_range "$1" |
51 |
[[ ${end} && ${end} -le $((${#comp[@]}/2)) ]] || end=$((${#comp[@]}/2)) |
52 |
- for (( i = start*2 - 1; i < end*2; i+=2 )); do |
53 |
+ for (( i = start*2; i <= end*2; i+=2 )); do |
54 |
comp[i]=$2 |
55 |
done |
56 |
shift 2 |