Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/eselect-python:master commit in: /
Date: Wed, 17 Apr 2019 10:47:23
Message-Id: 1555498031.cb7db35b2863967c327d76b1f8ec4dc77493ed7b.mgorny@gentoo
1 commit: cb7db35b2863967c327d76b1f8ec4dc77493ed7b
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 17 10:46:33 2019 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 17 10:47:11 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=cb7db35b
7
8 Fix mismatched indexes when looping over old impls
9
10 Bug: https://bugs.gentoo.org/683178
11 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
12
13 python.eselect.in | 8 +++++---
14 1 file changed, 5 insertions(+), 3 deletions(-)
15
16 diff --git a/python.eselect.in b/python.eselect.in
17 index 8c48b09..98b8cc9 100644
18 --- a/python.eselect.in
19 +++ b/python.eselect.in
20 @@ -182,7 +182,8 @@ do_cleanup() {
21 local prefs=( $(get_all_preferences) )
22
23 local i target_idx
24 - for (( i = 0; i < ${#prefs[@]}; ++i )); do
25 + local num_prefs=${#prefs[@]}
26 + for (( i = 0; i < num_prefs; ++i )); do
27 # remove preferences for uninstalled interpreters
28 if ! has "${prefs[i]#-}" "${installed[@]}"; then
29 unset 'prefs[i]'
30 @@ -419,7 +420,8 @@ do_set() {
31 local prefs=( $(get_all_preferences) )
32
33 local i target_idx
34 - for (( i = 0; i < ${#prefs[@]}; ++i )); do
35 + local num_prefs=${#prefs[@]}
36 + for (( i = 0; i < num_prefs; ++i )); do
37 # find first positive preference matching the filter
38 if [[ ! ${target_idx} ]]; then
39 if [[ ( ${filter} == --py? && ${prefs[i]} == python${filter:4}* ) \
40 @@ -433,7 +435,7 @@ do_set() {
41 [[ ${prefs[i]#-} == ${target} ]] && unset 'prefs[i]'
42 done
43 # if none matched, add to the bottom
44 - : "${target_idx=${#prefs[@]}}"
45 + : "${target_idx=${num_prefs}}"
46
47 # add between remaining preferences, before the one matching
48 # need to do this outta loop in case no pref matches