From 9f9042440db4e0cea11ecf363fa155571233e9ca Mon Sep 17 00:00:00 2001 From: gsell Date: Fri, 23 Aug 2024 13:31:14 +0200 Subject: [PATCH] Merge branch '332-modulecmd-use-of-unset-variable-in-sub-cmd-unuse' into 'master' Resolve "modulecmd: use of unset variable in sub-cmd unuse" Closes #332 See merge request Pmodules/src!311 (cherry picked from commit 59c116b70bb732f53f0c6381343a89ac94e77628) fefe313d modulecmd: use of unset variable fixed Co-authored-by: gsell --- Pmodules/modulecmd.bash.in | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 9c61f99..47419b7 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -1993,13 +1993,15 @@ subcommand_unuse() { "${arg}" fi - local var="PMODULES_LOADED_${arg^^}" - if [[ -n "${!var}" ]]; then - std::die 3 "%s %s: %s -- %s" \ - "${CMD}" "${SubCommand}" \ - "cannot remove group due to loaded modules" \ - "${arg}" - fi + if [[ -v PMODULES_LOADED_${arg^^} ]]; then + local var="PMODULES_LOADED_${arg^^}" + if [[ -n "${!var}" ]]; then + std::die 3 "%s %s: %s -- %s" \ + "${CMD}" "${SubCommand}" \ + "cannot remove group due to loaded modules" \ + "${arg}" + fi + fi std::remove_path UsedGroups "${arg}" local overlay for overlay in "${UsedOverlays[@]}"; do