diff options
author | Michał Górny <mgorny@gentoo.org> | 2019-04-17 12:46:33 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2019-04-17 12:47:11 +0200 |
commit | cb7db35b2863967c327d76b1f8ec4dc77493ed7b (patch) | |
tree | 4727144db5f79269bb28c3d6efbd9d493a07e75e | |
parent | Bump version to 20171204 (diff) | |
download | eselect-python-cb7db35b2863967c327d76b1f8ec4dc77493ed7b.tar.gz eselect-python-cb7db35b2863967c327d76b1f8ec4dc77493ed7b.tar.bz2 eselect-python-cb7db35b2863967c327d76b1f8ec4dc77493ed7b.zip |
Fix mismatched indexes when looping over old impls
Bug: https://bugs.gentoo.org/683178
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | python.eselect.in | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/python.eselect.in b/python.eselect.in index 8c48b09..98b8cc9 100644 --- a/python.eselect.in +++ b/python.eselect.in @@ -182,7 +182,8 @@ do_cleanup() { local prefs=( $(get_all_preferences) ) local i target_idx - for (( i = 0; i < ${#prefs[@]}; ++i )); do + local num_prefs=${#prefs[@]} + for (( i = 0; i < num_prefs; ++i )); do # remove preferences for uninstalled interpreters if ! has "${prefs[i]#-}" "${installed[@]}"; then unset 'prefs[i]' @@ -419,7 +420,8 @@ do_set() { local prefs=( $(get_all_preferences) ) local i target_idx - for (( i = 0; i < ${#prefs[@]}; ++i )); do + local num_prefs=${#prefs[@]} + for (( i = 0; i < num_prefs; ++i )); do # find first positive preference matching the filter if [[ ! ${target_idx} ]]; then if [[ ( ${filter} == --py? && ${prefs[i]} == python${filter:4}* ) \ @@ -433,7 +435,7 @@ do_set() { [[ ${prefs[i]#-} == ${target} ]] && unset 'prefs[i]' done # if none matched, add to the bottom - : "${target_idx=${#prefs[@]}}" + : "${target_idx=${num_prefs}}" # add between remaining preferences, before the one matching # need to do this outta loop in case no pref matches |