Skip to content

Commit b8e95bb

Browse files
committed
Add "module-warn" modulefile command
Signed-off-by: Xavier Delaruelle <[email protected]>
1 parent 0e67022 commit b8e95bb

File tree

4 files changed

+65
-5
lines changed

4 files changed

+65
-5
lines changed

tcl/interp.tcl.in

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ proc initModfileModeAliases {mode auto aliasesVN aliasesPassArgVN\
100100
# the evaluation mode
101101
set ::g_modfileEvalModes {load unload display help test whatis refresh\
102102
scan}
103-
##nagelfar ignore #46 Too long line
103+
##nagelfar ignore #47 Too long line
104104
array set g_modfilePerModeAliases {
105105
add-property {add-property nop reportCmd nop nop nop nop nop}
106106
always-load {always-load nop reportCmd nop nop nop nop always-load-sc}
@@ -126,6 +126,7 @@ module-forbid {module-forbid module-forbid module-forbid module-forbid modu
126126
module-help {nop nop reportCmd module-help nop nop nop nop }
127127
module-hide {module-hide module-hide module-hide module-hide module-hide module-hide nop nop }
128128
module-tag {module-tag module-tag module-tag module-tag module-tag module-tag nop nop }
129+
module-warn {module-warn module-warn module-warn module-warn module-warn module-warn nop nop }
129130
module-whatis {nop nop reportCmd nop nop module-whatis nop nop }
130131
prepend-path {prepend-path prepend-path-un prepend-path prepend-path prepend-path edit-path-wh nop edit-path-sc}
131132
prereq-all {prereqAllModfileCmd nop reportCmd nop nop nop nop prereq-all-sc}
@@ -348,6 +349,11 @@ proc execute-modulefile {modfile modname modnamevrvar modspec requested\
348349
reportWarning [getNearlyForbiddenMsg $modnamevr $modfile]
349350
}
350351
}
352+
if {$mode ni {unload refresh scan whatis}} {
353+
if {[isModuleTagged $modnamevr warning 1 $modfile]} {
354+
reportWarning [getWarningMsg $modnamevr $modfile]
355+
}
356+
}
351357

352358
# record all module evaluated in scan structure for negation pattern search
353359
if {$mode eq {scan}} {
@@ -559,7 +565,8 @@ proc execute-modulerc {modfile modname modspec} {
559565
module-virtual module-forbid module-forbid module-hide module-hide\
560566
module-tag module-tag module-info module-info modulepath-label\
561567
modulepath-label setModulesVersion setModulesVersion\
562-
getModuleContent getModuleContent lsb-release lsb-release]
568+
getModuleContent getModuleContent lsb-release lsb-release\
569+
module-warn module-warn]
563570

564571
if {[getConf source_cache]} {
565572
set ::g_modrcAliases(source) sourceModfileCmd

tcl/main.tcl.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ proc parseModuleCommandArgs {topcall cmd ignerr args} {
295295

296296
foreach tag $tag_list {
297297
if {$tag in [list loaded auto-loaded forbidden nearly-forbidden\
298-
hidden]} {
298+
hidden warning]} {
299299
knerror "Tag '$tag' cannot be manually set"
300300
}
301301
}

tcl/mfcmd.tcl

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ proc module-tag {args} {
526526
knerror {No module specified in argument}
527527
}
528528
if {$tag in [list loaded auto-loaded forbidden nearly-forbidden hidden\
529-
hidden-loaded]} {
529+
hidden-loaded warning]} {
530530
knerror "'$tag' is a reserved tag name and cannot be set"
531531
}
532532

@@ -1143,7 +1143,7 @@ proc parsePrereqCommandArgs {cmd args} {
11431143

11441144
foreach tag $tag_list {
11451145
if {$tag in [list loaded auto-loaded forbidden nearly-forbidden\
1146-
hidden]} {
1146+
hidden warning]} {
11471147
knerror "Tag '$tag' cannot be manually set"
11481148
}
11491149
}
@@ -2323,6 +2323,55 @@ proc add-property {name value} {
23232323
}
23242324
}
23252325
2326+
proc module-warn {args} {
2327+
# parse application criteria arguments to determine if command apply
2328+
lassign [parseApplicationCriteriaArgs 1 0 {*}$args] apply isnearly after\
2329+
otherargs
2330+
2331+
# parse remaining argument list, do it even if command does not apply to
2332+
# raise any command specification error
2333+
foreach arg $otherargs {
2334+
if {[info exists nextargisval]} {
2335+
##nagelfar vartype nextargisval varName
2336+
set $nextargisval $arg
2337+
unset nextargisval
2338+
} else {
2339+
switch -glob -- $arg {
2340+
--message {
2341+
set nextargisval message
2342+
}
2343+
-* {
2344+
knerror "Invalid option '$arg'"
2345+
}
2346+
default {
2347+
lappend modarglist $arg
2348+
}
2349+
}
2350+
set prevarg $arg
2351+
}
2352+
}
2353+
2354+
if {[info exists nextargisval]} {
2355+
knerror "Missing value for '$prevarg' option"
2356+
}
2357+
if {![info exists message]} {
2358+
knerror {No message specified in argument}
2359+
}
2360+
if {![info exists modarglist]} {
2361+
knerror {No module specified in argument}
2362+
}
2363+
2364+
# skip tag record if application criteria are not met
2365+
if {$apply} {
2366+
##nagelfar ignore Found constant
2367+
set proplist [list message $message]
2368+
# record each hide spec after parsing them
2369+
foreach modarg [parseModuleSpecification 0 0 0 0 {*}$modarglist] {
2370+
setModspecTag $modarg warning $proplist
2371+
}
2372+
}
2373+
}
2374+
23262375
# ;;; Local Variables: ***
23272376
# ;;; mode:tcl ***
23282377
# ;;; End: ***

tcl/report.tcl.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,10 @@ proc getNearlyForbiddenMsg {mod fpmod} {
10851085
return $msg
10861086
}
10871087
1088+
proc getWarningMsg {mod fpmod} {
1089+
return [getModuleTagProp $mod $fpmod warning message]
1090+
}
1091+
10881092
proc getStickyUnloadMsg {{tag sticky}} {
10891093
return "Unload of $tag module skipped"
10901094
}

0 commit comments

Comments
 (0)