diff --git a/README.new b/README.new index 5532ff21e..1a4620606 100644 --- a/README.new +++ b/README.new @@ -114,3 +114,6 @@ Lmod 8.7+ * Issue #657: Added support for "module purge" in a TCL modulefile to unload all other modules on load. (8.7.30) * Issue #662: Fix bug where the version is very long (like git commit tags) (8.7.31) * Issue #665: Added support for getenv function in TCL modules +W.I.P: + (8.7.32) * Better handling of zsh shell functions in source_sh(). Must match "\n}\n" to find end of function. + diff --git a/messageDir/en.lua b/messageDir/en.lua index f895bd09b..d6772f7a3 100644 --- a/messageDir/en.lua +++ b/messageDir/en.lua @@ -204,7 +204,7 @@ See https://lmod.readthedocs.io/en/latest/260_sh_to_modulefile.html for details. m_Depend_Mods = "\n You will need to load all module(s) on any one of the lines below before the \"%{fullName}\" module is available to load.\n", m_Description = " Description:\n%{descript}\n\n", m_Direct_Load = "\n This module can be loaded directly: module load %{fullName}\n", - m_Extensions_head = "This is a list of module extensions \"module --nx avail ...\" to not show.\n", + m_Extensions_head = "This is a list of module extensions. Use \"module --nx avail ...\" to not show extensions.", m_Extensions_tail = "\nThese extensions cannot be loaded directly, use \"module spider extension_name\" for more information.\n", m_Family_Swap = "\nLmod is automatically replacing \"%{oldFullName}\" with \"%{newFullName}\".\n", m_For_System = ", for system: \"%{sname}\"", diff --git a/rt/common_funcs.sh b/rt/common_funcs.sh index 578d57e72..23e673e20 100644 --- a/rt/common_funcs.sh +++ b/rt/common_funcs.sh @@ -33,7 +33,7 @@ cleanUp () -e "s|='\\\\033|='\\\\\\\\033|g" \ -e "s|^User shell.*||" \ -e "s|\@git\@|$gitV|g" \ - -e "s|$PATH_to_SHA1/$SHA1SUM|PATH_to_HASHSUM|g" \ + -e "s| $PATH_to_SHA1/$SHA1SUM| PATH_to_HASHSUM|g" \ -e "s|/usr/.*/sha1sum|PATH_to_HASHSUM|g" \ -e "s|/bin/.*/sha1sum|PATH_to_HASHSUM|g" \ -e "s|:$PATH_to_LUA\([:;]\)|\1|g" \ diff --git a/rt/extensions/err.txt b/rt/extensions/err.txt index 635d1f825..e42d13599 100644 --- a/rt/extensions/err.txt +++ b/rt/extensions/err.txt @@ -2,7 +2,7 @@ step 1 lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version =========================== -Modules based on Lua: Version 8.6.12 2022-02-09 16:10 -06:00 +Modules based on Lua: Version 8.7.31 2023-08-09 12:41 -05:00 by Robert McLay mclay@tacc.utexas.edu =========================== step 2 @@ -27,7 +27,7 @@ ProjectDIR/rt/extensions/mf/Compiler/gcc/9 python/3.7 (L) ProjectDIR/rt/extensions/mf/Core TACC gcc/9.4 (L) intel/19.1 -This is a list of module extensions "module --nx avail ..." to not show. +This is a list of module extensions. Use "module --nx avail ..." to not show extensions. CC (E) a (E) b (E) These extensions cannot be loaded directly, use "module spider extension_name" for more information. Where: @@ -46,7 +46,7 @@ ProjectDIR/rt/extensions/mf/Compiler/gcc/9 python/3.7 (L) snake/3.9 (H) ProjectDIR/rt/extensions/mf/Core TACC gcc/9.4 (L) intel/19.1 -This is a list of module extensions "module --nx avail ..." to not show. +This is a list of module extensions. Use "module --nx avail ..." to not show extensions. CC (E) a (E) b (E) d (E) These extensions cannot be loaded directly, use "module spider extension_name" for more information. Where: @@ -73,7 +73,7 @@ ProjectDIR/rt/extensions/mf/Compiler/intel/19 python/3.7 (L) ProjectDIR/rt/extensions/mf/Core TACC gcc/9.4 intel/19.1 (L) -This is a list of module extensions "module --nx avail ..." to not show. +This is a list of module extensions. Use "module --nx avail ..." to not show extensions. CC (E) DDD (E) These extensions cannot be loaded directly, use "module spider extension_name" for more information. Where: diff --git a/rt/help/help.tdesc b/rt/help/help.tdesc index 8c5c9ade0..7d9b5dcd1 100644 --- a/rt/help/help.tdesc +++ b/rt/help/help.tdesc @@ -31,7 +31,7 @@ testdescript = { runLmod help amber # 4 runLmod --config # 5 runLmod --miniConfig # 6 - $LUA_EXEC $projectDir/src/lmod.in.lua bash --config_json 2> config.json + LD_PRELOAD= $LUA_EXEC $projectDir/src/lmod.in.lua bash --config_json 2> config.json runBase $LUA_EXEC $projectDir/src/chkJson < config.json # 7 diff --git a/rt/zsh_to_modulefile/err.txt b/rt/zsh_to_modulefile/err.txt index 69a089070..d72941435 100644 --- a/rt/zsh_to_modulefile/err.txt +++ b/rt/zsh_to_modulefile/err.txt @@ -2,9 +2,13 @@ step 1 lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version =========================== -Modules based on Lua: Version 8.6.9 2022-02-02 11:25 -04:00 +Modules based on Lua: Version 8.7.31 2023-08-09 12:41 -05:00 by Robert McLay mclay@tacc.utexas.edu =========================== step 2 buildSh2MF --from zsh ProjectDIR/rt/zsh_to_modulefile/tstScript.zsh =========================== +=========================== +step 3 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing load matt/1.0 +=========================== diff --git a/rt/zsh_to_modulefile/mf/matt/1.0.lua b/rt/zsh_to_modulefile/mf/matt/1.0.lua new file mode 100644 index 000000000..e0e468f76 --- /dev/null +++ b/rt/zsh_to_modulefile/mf/matt/1.0.lua @@ -0,0 +1 @@ +source_sh("zsh", pathJoin(os.getenv("testDir"), "rtm.sh")) diff --git a/rt/zsh_to_modulefile/out.txt b/rt/zsh_to_modulefile/out.txt index 8169e4ae3..64f121de6 100644 --- a/rt/zsh_to_modulefile/out.txt +++ b/rt/zsh_to_modulefile/out.txt @@ -10,5 +10,33 @@ prepend_path("PATH","ProjectDIR/rt/zsh_to_modulefile/bin") append_path("PATH","ProjectDIR/rt/zsh_to_modulefile/sbin") set_alias("fooAlias","foobin -q -l") set_shell_function("fooFunc","\ - echo \"arg1: $1\"\ + echo \"arg1: $1\"\ ","") +=========================== +step 3 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing load matt/1.0 +=========================== +LOADEDMODULES=matt/1.0; +export LOADEDMODULES; +__LMOD_REF_COUNT_MODULEPATH=ProjectDIR/rt/zsh_to_modulefile/mf:1; +export __LMOD_REF_COUNT_MODULEPATH; +MODULEPATH=ProjectDIR/rt/zsh_to_modulefile/mf; +export MODULEPATH; +_LMFILES_=ProjectDIR/rt/zsh_to_modulefile/mf/matt/1.0.lua; +export _LMFILES_; +_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={matt={fn="ProjectDIR/rt/zsh_to_modulefile/mf/matt/1.0.lua",fullName="matt/1.0",loadOrder=1,mcmdT={["ProjectDIR/rt/zsh_to_modulefile/rtm.sh"]={[[set_shell_function("_sp_multi_pathadd","\\ local IFS=':' \\ if [ \\"$_sp_shell\\"=zsh ]\\ then\\ emulate -L sh\\ fi\\ for pth in $2\\ do\\ for systype in ${_sp_compatible_sys_types}\\ do\\ _spack_pathadd \\"$1\\" \\"${pth}/${systype}\\"\\ done\\ done\\","")]],},},propT={},stackDepth=0,status="active",userName="matt/1.0",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/zsh_to_modulefile/mf",},systemBaseMPATH="ProjectDIR/rt/zsh_to_modulefile/mf",}'; +export _ModuleTable_; +_sp_multi_pathadd () { + local IFS=':' + if [ "$_sp_shell" = zsh ] + then + emulate -L sh + fi + for pth in $2 + do + for systype in ${_sp_compatible_sys_types} + do + _spack_pathadd "$1" "${pth}/${systype}" + done + done; +}; diff --git a/rt/zsh_to_modulefile/rtm.sh b/rt/zsh_to_modulefile/rtm.sh new file mode 100644 index 000000000..4fea4933d --- /dev/null +++ b/rt/zsh_to_modulefile/rtm.sh @@ -0,0 +1,11 @@ + _sp_multi_pathadd() { + local IFS=':' + if [ "$_sp_shell" = zsh ]; then + emulate -L sh + fi + for pth in $2; do + for systype in ${_sp_compatible_sys_types}; do + _spack_pathadd "$1" "${pth}/${systype}" + done + done + } diff --git a/rt/zsh_to_modulefile/zsh_to_modulefile.tdesc b/rt/zsh_to_modulefile/zsh_to_modulefile.tdesc index e024e9cf3..de6456d2c 100644 --- a/rt/zsh_to_modulefile/zsh_to_modulefile.tdesc +++ b/rt/zsh_to_modulefile/zsh_to_modulefile.tdesc @@ -1,5 +1,5 @@ -- -*- lua -*- -local testName = "sh_to_modulefile" +local testName = "zsh_to_modulefile" local zsh_path, found = findInPath("zsh", os.getenv("PATH")) @@ -26,6 +26,7 @@ testdescript = { runLmod --version # 1 runSh2MF --from zsh $(testDir)/tstScript.zsh # 2 + runLmod load matt/1.0 # 3 HOME=$ORIG_HOME cat _stdout.[0-9][0-9][0-9] > _stdout.orig diff --git a/tools/MF_Base.lua b/tools/MF_Base.lua index 11f8e63e6..4a46c0429 100644 --- a/tools/MF_Base.lua +++ b/tools/MF_Base.lua @@ -160,9 +160,9 @@ function M.processAliases(self, shellName, old, new, a) end local shellFuncPatt = { - bash = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "(})\n" }, - zsh = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "(})\n" }, - ksh = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "(})\n" }, + bash = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "\n(})\n" }, + zsh = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "\n(})\n" }, + ksh = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "\n(})\n" }, } local function l_extractFuncs(shellName, funcs) @@ -174,7 +174,7 @@ local function l_extractFuncs(shellName, funcs) local is, ie, Nm, Strt = funcs:find(namePatt) if (not is) then break end local js, je, End = funcs:find(trailingPatt, ie+1) - funcT[Nm] = funcs:sub(ie+1,js-1) + funcT[Nm] = funcs:sub(ie+1,js):gsub("\t"," ") funcs = funcs:sub(je+1,-1) end