diff --git a/modules-4.5.2/modulecmd.tcl.in b/modulecmd.tcl.in
index 3abd4ad..cf6cb3b 100644
--- a/modules-4.5.2/modulecmd.tcl.in
+++ b/modulecmd.tcl.in
@@ -10564,8 +10564,17 @@ proc cmdModuleAutoinit {} {
@VERSIONING@ setenv MODULE_VERSION_STACK @MODULES_RELEASE@@MODULES_BUILD@
@VERSIONING@}
- # initialize default MODULEPATH and LOADEDMODULES
- if {![info exists ::env(MODULEPATH)] || $::env(MODULEPATH) eq {}} {
+ # initialize MODULEPATH and LOADEDMODULES if found unset
+ if {![info exists ::env(MODULEPATH)]} {
+ setenv MODULEPATH {}
+ }
+ if {![info exists ::env(LOADEDMODULES)]} {
+ setenv LOADEDMODULES {}
+ }
+
+ # initialize user environment if found undefined (both MODULEPATH and
+ # LOADEDMODULES empty)
+ if {$::env(MODULEPATH) eq {} && $::env(LOADEDMODULES) eq {}} {
# set modpaths defined in modulespath config file if it exists, use file
# in etcdir if it exists, dot file in initdir elsewhere
set modulespath [expr {[file exists @etcdir@/modulespath] ?\
@@ -10580,17 +10589,8 @@ proc cmdModuleAutoinit {} {
}
}
- if {![info exists ::env(MODULEPATH)]} {
- setenv MODULEPATH {}
- }
- }
- if {![info exists ::env(LOADEDMODULES)]} {
- setenv LOADEDMODULES {}
- }
-
- # source initialization modulerc if any and if no env already initialized
- # use initrc file in etcdir if any, modulerc file in initdir otherwise
- if {$::env(MODULEPATH) eq {} && $::env(LOADEDMODULES) eq {}} {
+ # source initialization modulerc if any and if no env already initialized
+ # use initrc file in etcdir if any, modulerc file in initdir otherwise
set initrc [expr {[file exists @etcdir@/initrc] ? {@etcdir@/initrc} :\
{@initdir@/modulerc}}]
if {[file exists $initrc]} {