From d2a188b2474e66b47db700a9753cd87fa30d098c Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Wed, 8 Nov 2023 07:13:55 +0100 Subject: [PATCH] install/doc: add abort_on_error support for unload subcmd --- INSTALL.rst | 5 +++-- NEWS.rst | 2 ++ configure | 7 ++++--- doc/source/design/evaluation-errors.rst | 16 ++++++++++++---- doc/source/module.rst | 5 ++++- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/INSTALL.rst b/INSTALL.rst index 21ee9c4c..4657aee8 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -746,8 +746,9 @@ instance :instopt:`--without-modulepath<--with-modulepath>`): When evaluating multiple modulefiles, if one fails abort evaluation sequence and withdraw already evaluated modulefiles for listed module sub-commands. - Sub-commands accepted in LIST are: :subcmd:`load`, :subcmd:`mod-to-sh` and - :subcmd:`try-load` (elements in LIST are separated by ``:``). (default=) + Sub-commands accepted in LIST are: :subcmd:`load`, :subcmd:`mod-to-sh`, + :subcmd:`try-load` and :subcmd:`unload` (elements in LIST are separated by + ``:``). (default=) This installation option defines the default value of the :mconfig:`abort_on_error` configuration option which could be changed after diff --git a/NEWS.rst b/NEWS.rst index d513f666..c6d5963e 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -83,6 +83,8 @@ Modules 5.4.0 (not yet released) by default. When set, it defines the :envvar:`MODULES_SOURCE_CACHE` environment variable. Default value can be changed with :instopt:`--enable-source-cache` installation option. +* Add support for :mconfig:`abort_on_error` evaluation behavior on + :subcmd:`unload` sub-command. .. _5.3 release notes: diff --git a/configure b/configure index a6fb922b..563131b5 100755 --- a/configure +++ b/configure @@ -386,8 +386,9 @@ Optional Packages: list of sub-commands that should abort when a module evaluation fails instead of continuing their evaluation sequence. sub-commands accepted in LIST - are: \`load', \`mod-to-sh' and \`try-load' (elements - in LIST are separated by \`:') [$abortonerror] + are: \`load', \`mod-to-sh', \`try-load' and + \`unload' (elements in LIST are separated by \`:') + [$abortonerror] --with-avail-output=LIST specify content to report on avail sub-command regular output. elements accepted in LIST are: @@ -782,7 +783,7 @@ for arg in "$@"; do fi ;; --with-abort-on-error*|--without-abort-on-error) abortonerror=$(get_package_value "$arg" "$abortonerror") ; - allowedval=" load mod-to-sh try-load " ; + allowedval=" load mod-to-sh try-load unload " ; ORIG_IFS=$IFS ; IFS=: ; for val in $abortonerror; do diff --git a/doc/source/design/evaluation-errors.rst b/doc/source/design/evaluation-errors.rst index 7c2008b4..750fc609 100644 --- a/doc/source/design/evaluation-errors.rst +++ b/doc/source/design/evaluation-errors.rst @@ -335,11 +335,19 @@ Multiple modulefiles passed as argument When multiple modulefiles are passed to the ``unload`` sub-command for evaluation. If the evaluation of one modulefile raises an error, behavior for -this error is applied and: +this error is applied and if: -* already evaluated modulefiles from the argument list are kept unloaded -* for other kind of error, evaluation continues with next modulefile in - argument list +* :mconfig:`abort_on_error` configuration option does not contain ``unload``: + + * already evaluated modulefiles from the argument list are kept unloaded + * for other kind of error, evaluation continues with next modulefile in + argument list + +* :mconfig:`abort_on_error` configuration option contains ``load``: + + * already evaluated modulefiles from the argument list are withdrawn (they + will appear loaded again and their environment changes are untouched) + * evaluation stops The above description only applies to ``unload`` sub-command executed from the top level context and not from a modulefile evaluation. Multiple arguments on diff --git a/doc/source/module.rst b/doc/source/module.rst index 544355a3..1f2d4c82 100644 --- a/doc/source/module.rst +++ b/doc/source/module.rst @@ -2464,7 +2464,9 @@ Module Sub-Commands specified order. If one modulefile evaluation raises an error, unload sequence continues: unloaded modules prior the evaluation error are kept unloaded and sequence is resumed with the unload of remaining modulefile in - list. + list. Conversely, unload sequence is aborted and already unloaded modulefiles + are restored if :subcmd:`unload` sub-command is defined in + :mconfig:`abort_on_error` configuration option. .. only:: html @@ -3864,6 +3866,7 @@ ENVIRONMENT * :subcmd:`load` * :subcmd:`mod-to-sh` * :subcmd:`try-load` + * :subcmd:`unload` Module sub-commands not configured to follow the *abort on error* behavior, apply the *continue on error* behavior. In this case if one modulefile