Skip to content

Commit d455636

Browse files
committed
Ensure no autoinit loop when set_shell_startup set
Set the __MODULES_AUTOINIT_INPROGRESS environment variable when running the `autoinit` sub-command and quit autoinit process if this variable is found defined and equal to 1 when starting it. Ensure this way that an autoinit process will not be triggered indefinitely by itself when the set_shell_startup option is enabled and some module loaded at initialization time relies on the execution of a bash script. Fixes #414.
1 parent 9383dbe commit d455636

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tcl/subcmd.tcl.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,14 @@ proc cmdModuleUnuse {args} {
16681668
proc cmdModuleAutoinit {} {
16691669
reportDebug called.
16701670

1671+
# skip autoinit process if found already ongoing in current environment
1672+
if {[get-env __MODULES_AUTOINIT_INPROGRESS] eq {1}} {
1673+
return
1674+
}
1675+
1676+
# set environment variable to state autoinit process is ongoing
1677+
setenv __MODULES_AUTOINIT_INPROGRESS 1
1678+
16711679
# flag to make renderSettings define the module command
16721680
setState autoinit 1
16731681

@@ -1751,6 +1759,9 @@ proc cmdModuleAutoinit {} {
17511759
setenv BASH_ENV @initdir@/bash
17521760
}
17531761

1762+
# clear in progress flag
1763+
unsetenv __MODULES_AUTOINIT_INPROGRESS
1764+
17541765
lpopState mode
17551766
}
17561767

0 commit comments

Comments
 (0)