@@ -603,24 +603,30 @@ with_shim_executable() {
603603 }
604604
605605 select_version () {
606- # First, we get the all the plugin/version pairs where the
606+ # First, we get the all the plugins where the
607607 # current shim is available.
608- # Then, we iterate on these and check if the version of the current
609- # plugin is the one currently set.
608+ # Then, we iterate on all versions set for each plugin
610609 # Note that multiple plugin versions can be set for a single plugin.
611610 # These are separated by a space. e.g. python 3.7.2 2.7.15
612- # Therefore, we iterate on all the versions set for the plugin
613- # and return if we find a version which matches the shim plugin/version pair
611+ # For each plugin/version pair, we check if it is present in the shim
614612 local search_path
615613 search_path=$( pwd)
616614 local shim_versions
617615 IFS=$' \n ' read -rd ' ' -a shim_versions <<< " $(get_shim_versions)"
618616
617+ local plugins
618+ plugins=()
619+
619620 for plugin_and_version in " ${shim_versions[@]} " ; do
620621 local plugin_name
621622 local plugin_shim_version
622- IFS=' ' read -r plugin_name plugin_shim_version <<< " $plugin_and_version"
623+ IFS=' ' read -r plugin_name _plugin_shim_version <<< " $plugin_and_version"
624+ if ! [[ " ${plugins[*]} " == * " $plugin_name " * ]]; then
625+ plugins+=(" $plugin_name " )
626+ fi
627+ done
623628
629+ for plugin_name in " ${plugins[@]} " ; do
624630 local version_and_path
625631 local version_string
626632 local usable_plugin_versions
@@ -629,10 +635,16 @@ with_shim_executable() {
629635 IFS=' |' read -r version_string _path <<< " $version_and_path"
630636 IFS=' ' read -r -a usable_plugin_versions <<< " $version_string"
631637 for plugin_version in " ${usable_plugin_versions[@]} " ; do
632- if [ " $plugin_version " = " $plugin_shim_version " ]; then
633- echo " $plugin_name $plugin_version "
634- return
635- fi
638+ for plugin_and_version in " ${shim_versions[@]} " ; do
639+ local plugin_shim_name
640+ local plugin_shim_version
641+ IFS=' ' read -r plugin_shim_name plugin_shim_version <<< " $plugin_and_version"
642+ if [[ " $plugin_name " = " $plugin_shim_name " ]] &&
643+ [[ " $plugin_version " = " $plugin_shim_version " ]]; then
644+ echo " $plugin_name $plugin_version "
645+ return
646+ fi
647+ done
636648 done
637649 done
638650 }
0 commit comments