modulecmd: bugfix in use/unuse overlay

- Since Pmodules itself can be loaded as module, it must be possible
  to add/remove overlays if no modules are loaded or only a Pmodules
  module.
This commit is contained in:
2021-04-22 09:48:27 +02:00
parent 5661f69169
commit b62841239c
+4 -5
View File
@@ -1323,7 +1323,7 @@ subcommand_use() {
use () {
use_overlay() {
if [[ -n "${_LMFILES_}" ]]; then
if [[ -n "${_LMFILES_}" ]] && [[ ${LOADEDMODULES} != Pmodules/* ]]; then
std::die 3 "%s %s: %s -- %s" \
"${CMD}" "${subcommand}" \
"overlays can be added as long as no modules are loaded!" \
@@ -1529,12 +1529,11 @@ subcommand_unuse() {
unuse() {
unuse_overlay() {
[[ -n "${_LMFILES_}" ]] && \
std::die 3 "%s %s: %s -- %s" \
if [[ -n "${_LMFILES_}" ]] && [[ ${LOADEDMODULES} != Pmodules/* ]]; then std::die 3 "%s %s: %s -- %s" \
"${CMD}" "${subcommand}" \
"overlays can be removed as long as modules are loaded!" \
"overlays can NOT be removed as long as modules are loaded!" \
"${overlay}"
fi
overlay=${overlay%:*} # ignore any modifier
overlay=${overlay%/} # remove trailing '/' if there is one
[[ -d "${overlay}" ]] || \