diff --git a/CHANGELOG.md b/CHANGELOG.md index 30b7827..b91bf82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## Version 2.0.3 ### modulecmd +* It was not possible to load a module with it's absolute path. + (#1343) * Bugfix in unloading modules. Under certain conditions unloading a module failed due to a wrong check in the test whether a module is loaded or not. (#1340) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index a6078c2..2c25214 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -1398,19 +1398,32 @@ find_modulefile(){ local -a modulepath=() IFS=':' read -r -a modulepath <<<"${MODULEPATH}" - local -a mods=() - local -- relstages="${UsedReleaseStages}" - [[ "${modulename}" = */* ]] && relstages="${ReleaseStages}" - get_available_modules \ - 'load' \ - mods \ - "${modulename}" \ - "${relstages}" \ - "${modulepath[@]}" - (( ${#mods[@]} == 0 )) && return 1 - ref_relstage="${mods[1]}" - ref_moduledir="${mods[2]}" - ref_modulefile="${mods[2]}/${mods[3]}" + if [[ "${m:0:1}" = '/' || -r "${m}" ]]; then + # handle absolut or relative module names + local -- absname=$(std::get_abspath "${m}") + local -- ol_name='' + local -- group='' + find_overlay ol_name group "${absname}" + [[ "${ol_name}" != 'none' ]] && \ + die_ol_absname_not_allowed "${m}" + ref_modulefile="${absname}" + ref_relstage='stable' + ref_moduledir="${absname%/*}" + else + local -a mods=() + local -- relstages="${UsedReleaseStages}" + [[ "${modulename}" = */* ]] && relstages="${ReleaseStages}" + get_available_modules \ + 'load' \ + mods \ + "${modulename}" \ + "${relstages}" \ + "${modulepath[@]}" + (( ${#mods[@]} == 0 )) && return 1 + ref_relstage="${mods[1]}" + ref_moduledir="${mods[2]}" + ref_modulefile="${mods[2]}/${mods[3]}" + fi is_modulefile ref_interp "${ref_modulefile}" || \ die_module_not_a_modulefile "${modulename}" if [[ "${modulecmd}" == "Lmod_cmd" ]]; then