Blame SOURCES/environment-modules-moulespath-initrc.patch

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