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 84b586e..871caf0 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -508,8 +508,20 @@ subcommand_load() { fi if [[ ${current_modulefile} =~ ${PMODULES_ROOT} ]] \ && [[ ! ${m} =~ / ]]; then + # the module is in our hierarchy but no version + # has been specified. We take the version from + # current_modulefile and append it m+="/${current_modulefile##*/}" fi + 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 continue fi @@ -1394,8 +1406,8 @@ pmodules_init() { unset UseFlags declare -Ag UseFlags=() declare -g Version="${PMODULES_VERSION}" - reset_modulepath reset_used_groups + reset_modulepath reset_used_releases init_manpath export_env \ @@ -1465,7 +1477,6 @@ subcommand_purge() { local output=$("${modulecmd}" 'bash' 'purge' 2> "${tmpfile}") local error=$( < "${tmpfile}") - ${rm} "${tmpfile}" if [[ "${error}" =~ ":ERROR:" ]]; then local s=${error%%$'\n'*} local error_txt='failed' @@ -1755,8 +1766,6 @@ subcommand_search() { func_print_line='print_line_csv' } - local -r tmpfile=$1 - if [[ "${opt_print_modulefiles}" == 'yes' ]]; then print_modulefiles elif [[ "${opt_print_csv}" == 'yes' ]]; then @@ -1852,7 +1861,6 @@ subcommand_search() { done done print_result "${tmpfile}" - ${rm} -f "${tmpfile}" } while (( $# > 0 )); do @@ -2262,7 +2270,16 @@ fi 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 + _LMFILES_="${saved_LMFILES_}" + LOADEDMODULES="${saved_LOADEDMODULES}" + export_env _LMFILES_ LOADEDMODULES fi else pmodules_init @@ -2277,6 +2294,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