cea-hpc / modules

Environment Modules: provides dynamic modification of a user's environment
http://modules.sourceforge.net/
GNU General Public License v2.0
668 stars 102 forks source link

Allow modules to ommit exit 1 calls to mimik modules 3 behaviour #472

Closed wenzler closed 1 year ago

wenzler commented 1 year ago

Describe the solution you'd like

Hey Xavier, I again have one of those nice requests :) We'd need to be able to turn off exit codes for modules, like it was in modules 3

Something like this maybe in

proc cleanupAndExit {code} {
....
  if {![getState inhibit_errreport]} {
     exit $code
  } else { exit 0 }
}

Describe alternatives you've considered

Seems nothing from siteconfig can influence this behavior, correct?

Thanks and BR Seb

xdelaruelle commented 1 year ago

Hi @wenzler

Do you mean to get 0 exit code and the end of modulecmd.tcl code evaluation even if an error occurs ?

For instance:

$ module load unknown_module
ERROR: Unable to locate a modulefile for 'unknown_module'
$ echo $?
0
wenzler commented 1 year ago

Yes, exactly

xdelaruelle commented 1 year ago

In siteconfig.tcl you may set the false_rendered state to indicate the shell code for exit code has already been produced:

setState false_rendered 1
wenzler commented 1 year ago

Works - thanks a lot!

Maybe something for the cookbook then? etc/siteconfig.tcl:

if {[info exists ::env(MODULES_NO_EXITCODES)]} { setState false_rendered 1 }

xdelaruelle commented 1 year ago

Maybe something for the cookbook then? etc/siteconfig.tcl:

if {[info exists ::env(MODULES_NO_EXITCODES)]} {
setState false_rendered 1
}

This is not something I will work on, but I will accept such cookbook entry as contribution.