diff --git a/Pmodules/libstd.bash b/Pmodules/libstd.bash index eb8525d..e5a2f46 100644 --- a/Pmodules/libstd.bash +++ b/Pmodules/libstd.bash @@ -244,6 +244,33 @@ std::get_os_release() { ${func_map[${OS}]} } +std::get_type() { + local -a signature=$(typeset -p "$1") + case ${signature[1]} in + -Ai* ) + echo 'int dict' + ;; + -A* ) + echo 'dict' + ;; + -ai* ) + echo 'int array' + ;; + -a* ) + echo 'array' + ;; + -i* ) + echo 'integer' + ;; + -- ) + echo 'string' + ;; + * ) + echo 'none' + return 1 + esac +} + # Local Variables: # mode: sh # sh-basic-offset: 8 diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index f3efa93..37037e5 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -593,8 +593,17 @@ subcommand_load() { std::die 3 "" fi fi - if [[ ":${LOADEDMODULES}:" =~ ":${m}:" ]]; then - # already loaded + if [[ ${m} == Pmodules/* ]] && [[ -n ${LOADEDMODULES} ]]; then + std::error "%s %s: %s" \ + "${CMD}" "${subcommand}" \ + "cannot load a Pmodules module because other modules are already load!" + std::die 3 "%s %s: %s -- %s\n" \ + "${CMD}" "${subcommand}" \ + "failed" \ + "${m}" + fi + if [[ ":${LOADEDMODULES}:" =~ ":${m}:" ]]; then + # already loaded continue fi @@ -1844,7 +1853,6 @@ pmodules_init() { unset UseFlags declare -Ag UseFlags=() declare -g Version="${PMODULES_VERSION}" - reset_used_groups reset_modulepath reset_used_releases @@ -2725,8 +2733,17 @@ _init_overlay_vars() { if [[ -n ${PMODULES_ENV} ]]; then eval "$("${base64}" -d <<< "${PMODULES_ENV}" 2>/dev/null)" if [[ -z ${Version} ]] || [[ ${Version} != ${PMODULES_VERSION} ]]; then + # the Pmodules version changed! + # we save _LMFILES_ and LOADEDMODULES and restore them + # later. Otherwise the Pmodules module would not be listed + # by module list + declare saved_LMFILES_="${_LMFILES_}" + declare saved_LOADEDMODULES="${LOADEDMODULES}" pmodules_init _init_overlay_vars + _LMFILES_="${saved_LMFILES_}" + LOADEDMODULES="${saved_LOADEDMODULES}" + export_env _LMFILES_ LOADEDMODULES fi else pmodules_init @@ -2741,6 +2758,9 @@ case ${subcommand} in declare -r tmpfile=$( ${mktemp} /tmp/Pmodules.XXXXXX ) \ || std::die 1 "Oops: unable to create tmp file!" ;; + * ) + declare -r tmpfile='' + ;; esac declare options