Skip to content

Add --regexp option to module-* commands and Lmod regex commands - #741

Merged
xdelaruelle merged 3 commits into
envmodules:mainfrom
xdelaruelle:module-regexp-spec
Nov 17, 2026
Merged

xdelaruelle merged 3 commits into
envmodules:mainfrom
xdelaruelle:module-regexp-spec

Conversation

@xdelaruelle

Copy link
Copy Markdown
Collaborator
  • Add a --regexp option to the module-hide, module-forbid, module-tag and module-warn modulefile commands. When set, all the module arguments of the command are Tcl regular expressions matched against module name and version, which helps to target with a single statement modules that do not share a name or version prefix (e.g., module-hide --regexp {-debug$}).
  • As a regular expression may start with a dash, an argument starting with - that is not a known option of the command is taken as a regular expression when --regexp is set, instead of raising an invalid option error. The Nagelfar lint plugins are adapted to accept such arguments.
  • Regular expressions follow the icase configuration option. For hiding, the strongest matching level is retained. For tag properties (like the forbid message), a matching module specification has precedence over regular expressions, and among them the first one defined wins. Stickiness set through a regular expression is only satisfied by the reload of the same module.
  • Add the module-hide-regex and module-forbid-regex modulerc commands, as aliases of module-hide --regexp and module-forbid --regexp, to support modulerc files written for Lmod. Expressions are Tcl regular expressions whereas they are Lua patterns on Lmod: no translation is made between these syntaxes.
  • Documentation (man page, design notes, changes, release notes), Nagelfar syntax databases, vim and emacs syntax files and testsuite are updated accordingly.

After a modulefile or modulerc evaluation, the commands defined in the
interpreter are compared to those initially recorded to recreate the
interpreter if some are missing. Both lists were compared as strings,
whereas "info commands" returns its result in an unspecified order.

This order may change when procedures are defined then deleted by an
evaluation. Interpreter was then recreated although all its commands
were still there. It occurs with Tcl 9.1 as soon as two commands are
added to the modulefile interpreter.

Sort the two lists when they differ to only recreate the interpreter if
their content is different.

The spread test modulefiles and modulercs override the first procedure
returned by "info procs" then check from another evaluation that this
first procedure is still overridden, which assumes a stable order. Name
explicitly the procedure they have always picked: auto_load_index.

Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Hiding, forbidding, tagging or warning about a set of modules that do
not share a common name or version prefix (e.g., all the "-debug"
builds or version 1 of several software) requires one statement per
module, as a module specification always starts with a module name.

Add a --regexp option to module-hide, module-forbid, module-tag and
module-warn to designate target modules with Tcl regular expressions
matched against module name and version. It is similar to the
module-hide-regex and module-forbid-regex commands of Lmod.

When this option is set, all the module arguments of the command are
regular expressions. As such expression may start with a dash (e.g.,
"-debug$"), an argument starting with this character that is not a
known option is then taken as a regular expression instead of raising
an invalid option error.

Regular expressions cannot be indexed per module root name like module
specifications, so they are recorded in dedicated structures and tested
against every module looked at.

Nagelfar reports an argument starting with a dash as a bad option, so
the lint plugins hide this leading dash when --regexp is set. Syntax of
module-forbid, module-tag and module-warn moves from option-value pairs
to options with a declared value, to describe the valueless --regexp.

Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Lmod provides the module-hide-regex and module-forbid-regex commands in
its Tcl modulerc files to hide or forbid the modules matching a regular
expression. A modulerc file using them raises an unknown command error
when evaluated by Modules.

Add these two commands as aliases of module-hide and module-forbid with
--regexp option set, like hide-version and hide-modulefile are aliases
of module-hide. They accept the same options than the command they
rely on.

Expressions are Tcl regular expressions whereas they are Lua patterns
on Lmod. No translation is made between these syntaxes: expressions
using constructs specific to Lua patterns have to be adapted.

Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
@xdelaruelle
xdelaruelle merged commit 69c4ccc into envmodules:main Nov 17, 2026
22 checks passed
@xdelaruelle
xdelaruelle deleted the module-regexp-spec branch November 17, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant