From 8237e61ab26e61025be9ae197d2d5170574d20bb Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 9 Dec 2021 18:02:40 +0100 Subject: [PATCH] modulecmd: restrict removing overlays to top on stack --- Pmodules/modulecmd.bash.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 8c7d659..b0a5562 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -1656,6 +1656,14 @@ subcommand_unuse() { "not an used overlay" \ "${ol_name_or_dir%:*}" + # make sure first index is '0' (it should, but you never know) + OverlayList=( "${OverlayList[@]}" ) + [[ "${ol_dir}" != "${OverlayList[0]}" ]] && \ + std::die 3 "%s %s: %s %s -- %s" \ + "${CMD}" "${subcommand}" \ + "overlay cannot be removed since" \ + "it not on top of the stack" \ + "${ol_name_or_dir%:*}" if [[ "${OverlayDict[${ol_dir}]}" == "${ol_replacing}" ]]; then # if this overlay hides groups, we have to re-add # the modules made available by other overlays