diff --git a/README.new b/README.new index ef75ca58a..1a4620606 100644 --- a/README.new +++ b/README.new @@ -113,5 +113,7 @@ Lmod 8.7+ * Update zsh and bash tab completion files * 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.31) * Better handling of zsh shell functions in source_sh(). Must match "\n}\n" to find end of function. + (8.7.32) * Better handling of zsh shell functions in source_sh(). Must match "\n}\n" to find end of function. + diff --git a/docs/source/conf.py b/docs/source/conf.py index 78bc9b546..af948a895 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -57,7 +57,7 @@ # The short X.Y version. version = '8.7' # The full version, including alpha/beta/rc tags. -release = '8.7.30' +release = '8.7.31' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -377,5 +377,6 @@ + diff --git a/rt/tclmodules/err.txt b/rt/tclmodules/err.txt index d0fd708c0..92291bfbb 100644 --- a/rt/tclmodules/err.txt +++ b/rt/tclmodules/err.txt @@ -2,7 +2,7 @@ step 1 lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version =========================== -Modules based on Lua: Version 8.7.20 2023-03-16 11:43 -05:00 +Modules based on Lua: Version 8.7.30 2023-07-21 17:13 -05:00 by Robert McLay mclay@tacc.utexas.edu =========================== step 2 @@ -33,7 +33,8 @@ step 6 lua ProjectDIR/src/lmod.in.lua shell --regression_testing avail =========================== ProjectDIR/rt/tclmodules/mf - a/1.0 earlyLateOutput/2.0 (L) hide/1.0 hide/2.0 (D) showMe/1.0 + a/1.0 getenv/1.0 hide/2.0 (D) + earlyLateOutput/2.0 (L) hide/1.0 showMe/1.0 Where: D: Default Module L: Module is loaded @@ -42,3 +43,8 @@ If the avail list is too long consider trying: "module overview" or "ml ov" to display the number of modules for each name. Use "module spider" to find all possible modules and extensions. Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys". +=========================== +step 7 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing load getenv +=========================== +FOUND diff --git a/rt/tclmodules/mf/getenv/1.0 b/rt/tclmodules/mf/getenv/1.0 new file mode 100644 index 000000000..1a4f4533d --- /dev/null +++ b/rt/tclmodules/mf/getenv/1.0 @@ -0,0 +1,8 @@ +#%Module + +if { {BAR} eq [getenv FOO] } { + puts stderr "FOUND" +} else { + puts stderr "NOT FOUND" +} + diff --git a/rt/tclmodules/out.txt b/rt/tclmodules/out.txt index b2e78818a..8b59d800d 100644 --- a/rt/tclmodules/out.txt +++ b/rt/tclmodules/out.txt @@ -55,3 +55,15 @@ MODULEPATH=ProjectDIR/rt/tclmodules/mf; export MODULEPATH; _ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={earlyLateOutput={fn="ProjectDIR/rt/tclmodules/mf/earlyLateOutput/2.0",fullName="earlyLateOutput/2.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="earlyLateOutput",wV="000000002.*zfinal",},},mpathA={"ProjectDIR/rt/tclmodules/mf",},systemBaseMPATH="ProjectDIR/rt/tclmodules/mf",}'; export _ModuleTable_; +=========================== +step 7 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing load getenv +=========================== +LOADEDMODULES=earlyLateOutput/2.0:getenv/1.0; +export LOADEDMODULES; +MODULEPATH=ProjectDIR/rt/tclmodules/mf; +export MODULEPATH; +_LMFILES_=ProjectDIR/rt/tclmodules/mf/earlyLateOutput/2.0:ProjectDIR/rt/tclmodules/mf/getenv/1.0; +export _LMFILES_; +_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={earlyLateOutput={fn="ProjectDIR/rt/tclmodules/mf/earlyLateOutput/2.0",fullName="earlyLateOutput/2.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="earlyLateOutput",wV="000000002.*zfinal",},getenv={fn="ProjectDIR/rt/tclmodules/mf/getenv/1.0",fullName="getenv/1.0",loadOrder=2,propT={},stackDepth=0,status="active",userName="getenv",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/tclmodules/mf",},systemBaseMPATH="ProjectDIR/rt/tclmodules/mf",}'; +export _ModuleTable_; diff --git a/rt/tclmodules/tclmodules.tdesc b/rt/tclmodules/tclmodules.tdesc index 2a3909e3c..86e8c5c29 100644 --- a/rt/tclmodules/tclmodules.tdesc +++ b/rt/tclmodules/tclmodules.tdesc @@ -20,6 +20,7 @@ testdescript = { unsetMT initStdEnvVars export MODULEPATH=$(testDir)/mf + export FOO=BAR rm -fr _stderr.* _stdout.* err.* out.* .lmod.d .cache .config @@ -29,7 +30,7 @@ testdescript = { runLmod list # 4 runLmod show showMe # 5 runLmod avail # 6 - + runLmod load getenv # 7 HOME=$ORIG_HOME cat _stdout.[0-9][0-9][0-9] > _stdout.orig diff --git a/settarg/Version.lua b/settarg/Version.lua index 542833165..2501a8ce5 100644 --- a/settarg/Version.lua +++ b/settarg/Version.lua @@ -1,12 +1,12 @@ local M={} -function M.tag() return "8.7.30" end +function M.tag() return "8.7.31" end function M.git() local s = "@git@" if (s == "@" .. "git@") then s = "" end if (s == M.tag() ) then s = "" end return s == "" and s or "("..s..")" end -function M.date() return "2023-07-21 17:13 -05:00" end +function M.date() return "2023-08-09 12:41 -05:00" end function M.name() local a = {} a[#a+1] = M.tag() diff --git a/src/Version.lua b/src/Version.lua index 542833165..2501a8ce5 100644 --- a/src/Version.lua +++ b/src/Version.lua @@ -1,12 +1,12 @@ local M={} -function M.tag() return "8.7.30" end +function M.tag() return "8.7.31" end function M.git() local s = "@git@" if (s == "@" .. "git@") then s = "" end if (s == M.tag() ) then s = "" end return s == "" and s or "("..s..")" end -function M.date() return "2023-07-21 17:13 -05:00" end +function M.date() return "2023-08-09 12:41 -05:00" end function M.name() local a = {} a[#a+1] = M.tag() diff --git a/src/tcl2lua.tcl b/src/tcl2lua.tcl index 1f24ef5fa..3a84f10c8 100755 --- a/src/tcl2lua.tcl +++ b/src/tcl2lua.tcl @@ -468,6 +468,10 @@ proc setenv { var val args } { cmdargs "setenv" $var $val } +proc getenv { var args } { + cmdargs "os.getenv" $var +} + proc unsetenv { var {val {}}} { global env g_varsT set mode [currentMode] @@ -996,9 +1000,10 @@ proc execute-modulefile {modfile } { interp alias $child complete {} complete interp alias $child conflict {} conflict interp alias $child depends-on {} depends-on - interp alias $child exit {} my_exit + interp alias $child exit {} my_exit interp alias $child extensions {} extensions interp alias $child family {} family + interp alias $child getenv {} getenv interp alias $child haveDynamicMPATH {} haveDynamicMPATH interp alias $child initGA {} initGA interp alias $child is-loaded {} is-loaded @@ -1077,6 +1082,16 @@ proc execute-modulefile {modfile } { return $errorVal } +proc getenv {var} { + + global env + set v "" + if {[info exists env($var)]} { + set v $env($var) + } + return $v +} + proc unset-env {var} { global env @@ -1084,6 +1099,7 @@ proc unset-env {var} { unset env($var) } } + proc set-env {var value} { global g_envT g_envClrT env # If setting a var not seen then mark it for deletion when reset is called.