diff -up modules-3.2.10/ModuleCmd_Load.c.unload_from_modulefile modules-3.2.10/ModuleCmd_Load.c --- modules-3.2.10/ModuleCmd_Load.c.unload_from_modulefile 2014-07-08 10:43:41.615212949 +0200 +++ modules-3.2.10/ModuleCmd_Load.c 2014-07-08 13:49:21.674701003 +0200 @@ -126,7 +126,7 @@ int ModuleCmd_Load( Tcl_Interp *interp, ** Set up the flags controling the Tcl callback functions **/ - /* avoid changes when invoked as a subcommand */ + /* avoid changes when invoked as a subcommand and loading */ if (!(g_flags & M_SUBCMD)) { if( load) { g_flags |= M_LOAD; @@ -136,6 +136,11 @@ int ModuleCmd_Load( Tcl_Interp *interp, g_flags &= ~M_LOAD; } g_flags |= M_SUBCMD; + } else { + if (!load) { + g_flags |= M_REMOVE; + g_flags &= ~M_LOAD; + } } /**