TACC / Lmod

Lmod: An Environment Module System based on Lua, Reads TCL Modules, Supports a Software Hierarchy
http://lmod.readthedocs.org
Other
480 stars 124 forks source link

Tcsh shell detection from script #630

Closed dougnd closed 1 year ago

dougnd commented 1 year ago

Notes Please note that we do not provide patches to older versions of Lmod, To speed up fixing your issue please test your bug against the latest version of Lmod. See: https://lmod.readthedocs.io/en/latest/045_transition.html if you want to install the latest version in your own account.

Describe the bug Shell detection seems to always return "bash" when module is called in tcsh shell script (using shebang). Note, this detection seemed to work as expected in earlier versions (in particular, it worked in Lmod 8.7.7 ).

To Reproduce Steps to reproduce the behavior:

  1. Create the following tcsh script as test.csh:
#!/bin/tcsh

( module -D --terse avail foobar ) |& grep shellNm

If you run directly through tcsh, it seems to work:

[dndawso@login002 236594]$ tcsh ./test.csh
  shellNm: tcsh, Shell:name(): tcsh

If you run using shebang, it doesn't detect as tcsh properly:

[dndawso@login002 236594]$ ./test.csh
  shellNm: bash, Shell:name(): bash

Expected behavior

I'd expect that running ./test.csh results in the shell being detected as tcsh.

Desktop (please complete the following information):

Modules based on Lua: Version 8.7.19 2023-01-17 10:45 -06:00 by Robert McLay mclay@tacc.utexas.edu

Changes from Default Configuration

Name Where Set Default Value


LMOD_HAVE_LUA_TERM C no yes LMOD_PACKAGE_PATH D nil LMOD_PAGER C less /usr/bin/more LMOD_SYSTEM_DEFAULT_MODULES D unknown LMOD_TCLSH C tclsh /usr/bin/tclsh MODULEPATH_ROOT E /usr/share/modulefiles PATH_TO_LUA C lua /usr/bin/lua

Where Set -> D: default, E: environment, C: configuration lmod_cfg: lmod_config.lua SitePkg: SitePackage StdPkg: StandardPackage Other: Set somewhere outside of normal locations



**Additional context**
None that I can think of.  Please let me know if I can provide any more information!
rtmclay commented 1 year ago

Thanks for the bug report! I found three different issues related to this bug. One issue was the somehow the luaposix package on Rocky has a broken posix.readlink funciton which I now work around.

I was able to reproduce the issue and fix it for me. This fix will be part of 8.7.20 which will be released soon. I have updaed the main branch if you wish to test this fix.

dougnd commented 1 year ago

Awesome, thank you for digging in! It didn't occur to me that the luaposix package was a culprit. Thank you for the very quick fix.