diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 1bc4a78..4e20a23 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -1448,18 +1448,18 @@ subcommand_use() { esac if [[ "${ol_type}" == "${ol_replacing}" ]]; then - # if this overlay replaces groups, we have to remove - # the modules made available by other overlays in these groups + # if this overlay replaces groups, we have + # to remove the modules made available by + # other overlays in these groups for group in ${UsedGroups//:/ }; do - # first test whether this group is in the to be added overlay + # is this group in the to be added overlay? local dir="${ol_dir}/" dir+="${group}/${PMODULES_MODULEFILES_DIR}" [[ -d "${dir}" ]] || continue # no - - for dir in "${OverlayList[@]}"; do - dir+="/${group}/${PMODULES_MODULEFILES_DIR}" - std::remove_path MODULEPATH "${dir}" - done + + dir="/${group}/${PMODULES_MODULEFILES_DIR}" + local -a dirs=( "${OverlayList[@]/%/${dir}}" ) + std::remove_path MODULEPATH "${dirs[@]}" done fi