Skip to content

Commit 57a85b0

Browse files
committed
Emulate $_ when using exec to run EB
1 parent da3ec20 commit 57a85b0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

easybuild/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ def main(args=None, logfile=None, do_build=None, testing=False, modtool=None):
230230
if 'CDPATH' in os.environ:
231231
del os.environ['CDPATH']
232232

233+
# When EB is run via `exec` the special bash variable $_ is not set
234+
# So emulate this here to allow (module) scripts depending on that to work
235+
if '_' not in os.environ:
236+
os.environ['_'] = os.path.basename(sys.executable or 'python')
237+
233238
# purposely session state very early, to avoid modules loaded by EasyBuild meddling in
234239
init_session_state = session_state()
235240

0 commit comments

Comments
 (0)