mirror of
https://github.com/envmodules/modules.git
synced 2026-06-14 00:42:43 +08:00
Introduce the __MODULES_QUARANTINE_SET environment variable to put back when starting modulecmd.tcl run the environment set on hold by initialization script (for autoinit calls) or by module shell function (for regular calls). This new environment variable is tested to apply quarantine unhold mechanism instead of checking if the run_quarantine configuration option is set and shell accurately supports the mecanishm. With this change it is possible to enable or disable the quarantine support at module initialization time (through initrc configuration file) instead of freezing this configuration when building the modulecmd.tcl script.
34 lines
1.2 KiB
Plaintext
34 lines
1.2 KiB
Plaintext
# define modules runtine quarantine configuration
|
|
@setquarvars@set env(MODULES_RUN_QUARANTINE) "@RUN_QUARANTINE@"
|
|
@setquarvars@@set env(RUNENV_VAR) "RUNENV_VAL"@
|
|
@notsetquarvars@#set env(MODULES_RUN_QUARANTINE) "ENVVARNAME"
|
|
@notsetquarvars@
|
|
# setup quarantine if defined
|
|
set _mlre {}; set _mlv ""; set _mlrv "";
|
|
if {[info exists env(MODULES_RUN_QUARANTINE)]} {
|
|
foreach _mlv [split $env(MODULES_RUN_QUARANTINE) " "] {
|
|
if {[regexp {^[A-Za-z_][A-Za-z0-9_]*$} $_mlv]} {
|
|
if {[info exists env($_mlv)]} {
|
|
lappend _mlre "__MODULES_QUAR_${_mlv}=$env($_mlv)"
|
|
}
|
|
set _mlrv "MODULES_RUNENV_${_mlv}"
|
|
if {[info exists env($_mlrv)]} {
|
|
lappend _mlre "${_mlv}=$env($_mlrv)"
|
|
} else {
|
|
lappend _mlre "${_mlv}="
|
|
}
|
|
}
|
|
}
|
|
if {[llength $_mlre] > 0} {
|
|
lappend _mlre "__MODULES_QUARANTINE_SET=1"
|
|
set _mlre [linsert $_mlre 0 "env"]
|
|
}
|
|
}
|
|
|
|
# define module command and surrounding initial environment (default value
|
|
# for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init config files)
|
|
eval [eval exec $_mlre "@TCLSH@" "@libexecdir@/modulecmd.tcl" "tcl" "autoinit" 2>@stderr]
|
|
|
|
# clean temp variables used to setup quarantine
|
|
unset _mlre _mlv _mlrv
|