Skip to content

Commit fb896f2

Browse files
committed
No require/incompat extra spec match if --not-req is set
Do not match module commands with --not-req option set on require or incompat extra specifier queries. Fixes #498
1 parent c70fda0 commit fb896f2

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

NEWS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Modules 5.3.1 (not yet released)
2727
(fix issue #496)
2828
* Fix extra specifier search when an identical module name and version is
2929
available in several modulepaths. (fix issue #497)
30+
* Do not match module commands with :mfcmd:`--not-req<module>` option set on
31+
``require`` or ``incompat`` extra specifier queries. (fix issue #498)
3032

3133
.. _Hunspell: https://hunspell.github.io/
3234

doc/source/module.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,8 @@ same trend ``prereq-all`` is an alias on ``depends-on`` and vice versa.
25772577
Regarding ``switch-off`` and ``switch-on`` elements they correspond
25782578
respectively to the module to unload (if specified) and the module to load on
25792579
a ``module switch`` command. ``switch`` is an alias that matches both
2580-
``switch-off`` and ``switch-on`` elements.
2580+
``switch-off`` and ``switch-on`` elements. ``require`` and ``incompat``
2581+
*elements* do not match module commands where ``--not-req`` option is set.
25812582

25822583
When several extra specifiers are set on a module search query, they act as an
25832584
*AND* operation. Which means modules listed in result are those matching all

tcl/modscan.tcl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,25 +172,36 @@ proc module-sc {command args} {
172172
show_mtime show_filter search_filter search_match dump_state\
173173
addpath_pos not_req tag_list args
174174
set modspeclist [parseModuleSpecification 0 0 0 0 {*}$args]
175+
176+
# no require/incompat extra specifier alias if --not-req option is set
177+
if {$not_req} {
178+
set xtaliasinc {}
179+
set xtaliasreq {}
180+
} else {
181+
set xtaliasinc [list incompat]
182+
set xtaliasreq [list require]
183+
}
184+
175185
if {$command eq {switch}} {
176186
# distinguish switched-off module spec from switched-on
177187
# ignore command without or with too much argument
178188
switch -- [llength $modspeclist] {
179189
{1} {
180190
# no switched-off module with one-arg form
181-
recordScanModuleElt $modspeclist switch switch-on require
191+
recordScanModuleElt $modspeclist switch switch-on\
192+
{*}$xtaliasreq
182193
}
183194
{2} {
184195
lassign $modspeclist swoffarg swonarg
185-
recordScanModuleElt $swoffarg switch switch-off incompat
186-
recordScanModuleElt $swonarg switch switch-on require
196+
recordScanModuleElt $swoffarg switch switch-off {*}$xtaliasinc
197+
recordScanModuleElt $swonarg switch switch-on {*}$xtaliasreq
187198
}
188199
}
189200
} else {
190-
set xtalias [expr {$command eq {unload} ? {incompat} : {require}}]
201+
set xtalias [expr {$command eq {unload} ? $xtaliasinc : $xtaliasreq}]
191202
# record each module spec
192203
foreach modspec $modspeclist {
193-
recordScanModuleElt $modspec $command $xtalias
204+
recordScanModuleElt $modspec $command {*}$xtalias
194205
}
195206
}
196207
}

0 commit comments

Comments
 (0)