From 4b4c51d652f59ebaf0ae39d6b5a681118514b95f Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 13 Aug 2024 15:51:09 +0200 Subject: [PATCH] modulecmd: eval output of modulecmd.bin only if not empty --- Pmodules/modulecmd.bash.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index fb5e805..78fc39e 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -959,12 +959,15 @@ subcommand_unload() { if [[ "${lmfile}" == '_zzzz_' ]]; then continue fi + # yes, module has been loaded local interp - is_modulefile modulecmd "${lmfile}" || die_not_a_modulefile "${lmfile}" + is_modulefile modulecmd "${lmfile}" || die_not_a_modulefile "${arg}" local output='' output=$("${modulecmd}" "${Shell}" 'unload' "${arg}") - eval "$(echo "${output}"|${sed} -e 's/;unalias [^;]*//g')" + if [[ -n "${output}" ]]; then + eval "$(echo "${output}"|${sed} -e 's/;unalias [^;]*//g')" + fi case ${Shell} in sh | bash | zsh ) echo "${output}"