Skip to content

Commit

Permalink
merging
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Jul 29, 2022
2 parents 459c510 + f4c1a3a commit 379bfac
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 62 deletions.
15 changes: 10 additions & 5 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ PATH_TO_TCLSH := @PATH_TO_TCLSH@
PATH_TO_LS := @PATH_TO_LS@
MODULEPATH_ROOT := @MODULEPATH_ROOT@
VERSION_SRC := $(srcdir)/src/Version.lua
SETTARG_VSRC := $(srcdir)/settarg/Version.lua
LUA_INCLUDE := @LUA_INCLUDE@
UPDATE_SYSTEM_FN := @UPDATE_SYSTEM_FN@
GIT_PROG := @PATH_TO_GIT@
Expand Down Expand Up @@ -253,7 +254,7 @@ __installMe:
-e 's|@use_dot_files@|$(USE_DOT_FILES)|g' \
-e 's|@lang@|$(LMOD_OVERRIDE_LANG)|g' \
-e 's|@site_msg_file@|$(SITE_MSG_FILE)|g' \
-e 's|@git@|($(GIT_VERSION))|g' \
-e 's|@git@|$(GIT_VERSION)|g' \
-e 's|--@ignore_dirs@--|$(IGNORE_DIRS)|g' \
-e 's|@sys_lua_path@|$(SYS_LUA_PATH)|g' \
-e 's|@hidden_italic@|$(LMOD_HIDDEN_ITALIC)|g' \
Expand Down Expand Up @@ -575,13 +576,14 @@ gittag:
echo "configure is out of date => try again"; \
else \
$(RM) $(VERSION_SRC); \
$(RM) $(SETTARG_VSRC); \
echo 'local M={}' > $(VERSION_SRC); \
echo 'function M.tag() return "$(TAG)" end' >> $(VERSION_SRC); \
echo 'function M.git()' >> $(VERSION_SRC); \
echo ' local s = "@git@"' >> $(VERSION_SRC); \
echo ' if (s == "@" .. "git@") then s = "" end' >> $(VERSION_SRC); \
echo ' if (s == "("..M.tag()..")") then s = "" end' >> $(VERSION_SRC); \
echo ' return s' >> $(VERSION_SRC); \
echo ' if (s == "@" .. "git@") then s = "" end' >> $(VERSION_SRC); \
echo ' if (s == M.tag() ) then s = "" end' >> $(VERSION_SRC); \
echo ' return s == "" and s or "("..s..")"' >> $(VERSION_SRC); \
echo 'end' >> $(VERSION_SRC); \
echo 'function M.date() return "$(VDATE)" end' >> $(VERSION_SRC); \
echo 'function M.name()' >> $(VERSION_SRC); \
Expand All @@ -592,8 +594,11 @@ gittag:
echo ' return table.concat(a," ")' >> $(VERSION_SRC); \
echo 'end' >> $(VERSION_SRC); \
echo 'return M' >> $(VERSION_SRC); \
cp $(VERSION_SRC) $(SETTARG_VSRC); \
$(UPDATE_VERSION) -p $(CONF_PY_PATTERN) --version $(TAG) $(CONF_PY); \
git commit -m "moving to TAG_VERSION $(TAG)" $(CONF_PY) $(VERSION_SRC); \
git commit -m "moving to TAG_VERSION $(TAG)" $(SETTARG_VSRC) \
$(CONF_PY) \
$(VERSION_SRC); \
git tag -a $(TAG) -m 'Setting TAG_VERSION to $(TAG)' ; \
branchName=`git status | head -n 1 | sed 's/^[# ]*On branch //g'` ; \
git push origin $$branchName ; \
Expand Down
5 changes: 3 additions & 2 deletions README.new
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ Lmod 8.7+
* Issue #593: In DirTree.lua l_versionFile(), Now only evaluate the highest priority
entry in defaultA, instead of all. This avoids the issue where there is a .modulerc.lua
which works and a .modulerc or .version file which has syntax errors.


(8.7.9) * Correctly generate Version.lua file when installing from a tar ball.


28 changes: 28 additions & 0 deletions docs/source/260_sh_to_modulefile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,34 @@ Lmod assumes that these scripts **DO NOT** have module commands or
change $MODULEPATH.


Shell script are evaluated with set -e
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Shell scripts are evaluated by sh_to_modulefile and the source_sh()
function with set -e in bash or equivalently in
other shells. This means that execution of the shell script stops at
the first time a statement in the script has a non-zero status.
Turning this option on means that Lmod can know that the evaluation of
the shell script has an issue. But this also means that sometimes a
script would work fine without using "set -e".

Assuming the script is a bash script, please do the following::

$ set -exv ; . ./my_script

This should tell you where the issue was found. Note that the error
may be in another script sourced by "my_script". In particular, you
might have a silent error. For example, a bash script might have a
line::

unalias some_alias_name 2> /dev/null

where "some_alias_name" is not currently an alias. This unalias statement
returns a non-zero status but is silent because of the redirection of
stderr to /dev/null. One fix might be::

unalias some_alias_name 2> /dev/null || true


Calling the shell script directly inside a modulefile
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
8 changes: 7 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# The short X.Y version.
version = '8.7'
# The full version, including alpha/beta/rc tags.
release = '8.7.8'
release = '8.7.9'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -340,6 +340,12 @@












Expand Down
6 changes: 5 additions & 1 deletion messageDir/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ Alternatively, you can set the environment variable LMOD_DISABLE_SAME_NAME_AUTOS
$ module spider %{sn}
for available versions.]==],
e_Sh_Error = "Error in script \"%{script}\": %{errorMsg}",
e_Sh_Error = [==[Error found in sourcing script "%{script}": %{errorMsg}
If this is a bash script please try:
$ set -exv; . %{script}
See https://lmod.readthedocs.io/en/latest/260_sh_to_modulefile.html for details.
]==],
e_Sh_convertSh2MF = "convertSh2MF script failed to produce 7 blocks\n",
e_Spdr_Timeout = "Spider search timed out.\n",
e_Swap_Failed = "Swap failed: \"%{name}\" is not loaded.\n",
Expand Down
46 changes: 30 additions & 16 deletions rt/sh_to_modulefile/err.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
step 1
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --version
===========================
Modules based on Lua: Version 8.6.16 2022-03-22 14:19 -05:00
Modules based on Lua: Version 8.7.9 2022-07-25 12:46 -05:00
by Robert McLay [email protected]
===========================
step 2
Expand All @@ -24,10 +24,21 @@ buildSh2MF --from csh ProjectDIR/rt/sh_to_modulefile/cshScript.csh
step 6
buildSh2MF ProjectDIR/rt/sh_to_modulefile/broken.sh
===========================
Error in script "ProjectDIR/rt/sh_to_modulefile/broken.sh":
Error found in sourcing script "ProjectDIR/rt/sh_to_modulefile/broken.sh":
ProjectDIR/rt/sh_to_modulefile/broken.sh: line 3: fooBar: command not found
If this is a bash script please try:
$ set -exv; . ProjectDIR/rt/sh_to_modulefile/broken.sh
See https://lmod.readthedocs.io/en/latest/260_sh_to_modulefile.html for details.
===========================
step 7
buildSh2MF ProjectDIR/rt/sh_to_modulefile/unalias.sh
===========================
Error found in sourcing script "ProjectDIR/rt/sh_to_modulefile/unalias.sh":
If this is a bash script please try:
$ set -exv; . ProjectDIR/rt/sh_to_modulefile/unalias.sh
See https://lmod.readthedocs.io/en/latest/260_sh_to_modulefile.html for details.
===========================
step 8
lua ProjectDIR/src/lmod.in.lua bash --regression_testing show wrapperSh/1.0
===========================
ProjectDIR/rt/sh_to_modulefile/mf/wrapperSh/1.0.lua:
Expand Down Expand Up @@ -66,11 +77,11 @@ setenv("MY_NAME","unknown")
source_sh("bash","ProjectDIR/rt/sh_to_modulefile/second.sh arg1")
setenv("SECOND","FOO_BAR")
===========================
step 8
step 9
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load wrapperSh/1.0
===========================
===========================
step 9
step 10
lua ProjectDIR/src/lmod.in.lua bash --regression_testing show wrapperSh/1.0
===========================
ProjectDIR/rt/sh_to_modulefile/mf/wrapperSh/1.0.lua:
Expand Down Expand Up @@ -109,17 +120,17 @@ setenv("MY_NAME","tstScript.sh")
source_sh("bash","ProjectDIR/rt/sh_to_modulefile/second.sh arg1")
setenv("SECOND","FOO_BAR")
===========================
step 10
step 11
lua ProjectDIR/src/lmod.in.lua bash --regression_testing refresh
===========================
===========================
step 11
step 12
lua ProjectDIR/src/lmod.in.lua bash --regression_testing list
===========================
Currently Loaded Modules:
1) wrapperSh/1.0
===========================
step 12
step 13
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --mt
===========================
_ModuleTable_ = {
Expand Down Expand Up @@ -173,34 +184,37 @@ _ModuleTable_ = {
systemBaseMPATH = "ProjectDIR/rt/sh_to_modulefile/mf",
}
===========================
step 13
step 14
lua ProjectDIR/src/lmod.in.lua bash --regression_testing unload wrapperSh/1.0
===========================
===========================
step 14
step 15
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load brokenSh/1.0
===========================
Lmod has detected the following error: Error in script "ProjectDIR/rt/sh_to_modulefile/broken.sh":
Lmod has detected the following error: Error found in sourcing script "ProjectDIR/rt/sh_to_modulefile/broken.sh":
ProjectDIR/rt/sh_to_modulefile/broken.sh: line 3: fooBar: command not found
If this is a bash script please try:
$ set -exv; . ProjectDIR/rt/sh_to_modulefile/broken.sh
See https://lmod.readthedocs.io/en/latest/260_sh_to_modulefile.html for details.
While processing the following module(s):
Module fullname Module Filename
brokenSh/1.0 ProjectDIR/rt/sh_to_modulefile/mf/brokenSh/1.0.lua
===========================
step 15
step 16
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load wrapperSh/1.0
===========================
===========================
step 16
step 17
lua ProjectDIR/src/lmod.in.lua bash --regression_testing save
===========================
Saved current collection of modules to: "default"
===========================
step 17
step 18
lua ProjectDIR/src/lmod.in.lua bash --regression_testing restore
===========================
Restoring modules from user's default
===========================
step 18
step 19
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --mt
===========================
_ModuleTable_ = {
Expand Down Expand Up @@ -254,11 +268,11 @@ _ModuleTable_ = {
systemBaseMPATH = "ProjectDIR/rt/sh_to_modulefile/mf",
}
===========================
step 19
step 20
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load A
===========================
===========================
step 20
step 21
lua ProjectDIR/src/lmod.in.lua bash --regression_testing list
===========================
Currently Loaded Modules:
Expand Down
30 changes: 17 additions & 13 deletions rt/sh_to_modulefile/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ buildSh2MF ProjectDIR/rt/sh_to_modulefile/broken.sh
===========================
===========================
step 7
buildSh2MF ProjectDIR/rt/sh_to_modulefile/unalias.sh
===========================
===========================
step 8
lua ProjectDIR/src/lmod.in.lua bash --regression_testing show wrapperSh/1.0
===========================
__LMOD_REF_COUNT_MODULEPATH=ProjectDIR/rt/sh_to_modulefile/mf:1;
Expand All @@ -112,7 +116,7 @@ export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/sh_to_modulefile/mf",},systemBaseMPATH="ProjectDIR/rt/sh_to_modulefile/mf",}';
export _ModuleTable_;
===========================
step 8
step 9
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load wrapperSh/1.0
===========================
LOADEDMODULES=wrapperSh/1.0;
Expand Down Expand Up @@ -160,15 +164,15 @@ save_args () {
};
[[ -n "${BASH_VERSION:-}" ]] && complete -F _xyz123 xyz123;
===========================
step 9
step 10
lua ProjectDIR/src/lmod.in.lua bash --regression_testing show wrapperSh/1.0
===========================
MODULEPATH=ProjectDIR/rt/sh_to_modulefile/mf;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={wrapperSh={fn="ProjectDIR/rt/sh_to_modulefile/mf/wrapperSh/1.0.lua",fullName="wrapperSh/1.0",loadOrder=1,mcmdT={["ProjectDIR/rt/sh_to_modulefile/second.sh arg1"]={"setenv(\"SECOND\",\"FOO_BAR\")",},["ProjectDIR/rt/sh_to_modulefile/tstScript.sh"]={"setenv(\"MY_NAME\",\"tstScript.sh\")","prepend_path(\"PATH\",\"ProjectDIR/rt/sh_to_modulefile/bin\")","append_path(\"PATH\",\"ProjectDIR/rt/sh_to_modulefile/sbin\")","setenv(\"TST_SCRIPT\",\"1\")","set_alias(\"fooAlias\",\"foobin -q -l\")",[[set_shell_function("banner"," \\ local str=\\"$1\\";\\ local RED='\\033[1;31m';\\ local NONE='\\033[0m';\\ echo \\"${RED}${str}${NONE}\\"\\","")]],[[set_shell_function("fooFunc"," \\ echo \\"arg1: $1\\"\\","")]],[[set_shell_function("junk"," \\ if [ -n \\"${ZSH_VERSION:-}\\" ]; then\\ \\\\echo \\"junk\\";\\ fi\\","")]],[[set_shell_function("my_help"," \\ echo \\"do not forget \\\\\\"foo\\\\\\"\\"\\","")]],[[set_shell_function("save_args"," \\ for arg in \\"$@\\";\\ do\\ printf \\"%s\\\\n\\" \\"$arg\\" | sed -e \\"s/'/'\\\\\\\\\\\\\\\\''/g\\" -e \\"1s/^/'/\\" -e \\"\\\\$s/\\\\$/' \\\\\\\\\\\\\\\\/\\";\\ done;\\ echo \\" \\"\\","")]],"complete(\"bash\",\"XyZ123\",\"-F _xyz123\")",},},propT={},stackDepth=0,status="active",userName="wrapperSh/1.0",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/sh_to_modulefile/mf",},systemBaseMPATH="ProjectDIR/rt/sh_to_modulefile/mf",}';
export _ModuleTable_;
===========================
step 10
step 11
lua ProjectDIR/src/lmod.in.lua bash --regression_testing refresh
===========================
MODULEPATH=ProjectDIR/rt/sh_to_modulefile/mf;
Expand Down Expand Up @@ -202,19 +206,19 @@ save_args () {
};
[[ -n "${BASH_VERSION:-}" ]] && complete -F _xyz123 xyz123;
===========================
step 11
step 12
lua ProjectDIR/src/lmod.in.lua bash --regression_testing list
===========================
MODULEPATH=ProjectDIR/rt/sh_to_modulefile/mf;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={wrapperSh={fn="ProjectDIR/rt/sh_to_modulefile/mf/wrapperSh/1.0.lua",fullName="wrapperSh/1.0",loadOrder=1,mcmdT={["ProjectDIR/rt/sh_to_modulefile/second.sh arg1"]={"setenv(\"SECOND\",\"FOO_BAR\")",},["ProjectDIR/rt/sh_to_modulefile/tstScript.sh"]={"setenv(\"MY_NAME\",\"tstScript.sh\")","prepend_path(\"PATH\",\"ProjectDIR/rt/sh_to_modulefile/bin\")","append_path(\"PATH\",\"ProjectDIR/rt/sh_to_modulefile/sbin\")","setenv(\"TST_SCRIPT\",\"1\")","set_alias(\"fooAlias\",\"foobin -q -l\")",[[set_shell_function("banner"," \\ local str=\\"$1\\";\\ local RED='\\033[1;31m';\\ local NONE='\\033[0m';\\ echo \\"${RED}${str}${NONE}\\"\\","")]],[[set_shell_function("fooFunc"," \\ echo \\"arg1: $1\\"\\","")]],[[set_shell_function("junk"," \\ if [ -n \\"${ZSH_VERSION:-}\\" ]; then\\ \\\\echo \\"junk\\";\\ fi\\","")]],[[set_shell_function("my_help"," \\ echo \\"do not forget \\\\\\"foo\\\\\\"\\"\\","")]],[[set_shell_function("save_args"," \\ for arg in \\"$@\\";\\ do\\ printf \\"%s\\\\n\\" \\"$arg\\" | sed -e \\"s/'/'\\\\\\\\\\\\\\\\''/g\\" -e \\"1s/^/'/\\" -e \\"\\\\$s/\\\\$/' \\\\\\\\\\\\\\\\/\\";\\ done;\\ echo \\" \\"\\","")]],"complete(\"bash\",\"XyZ123\",\"-F _xyz123\")",},},propT={},stackDepth=0,status="active",userName="wrapperSh/1.0",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/sh_to_modulefile/mf",},systemBaseMPATH="ProjectDIR/rt/sh_to_modulefile/mf",}';
export _ModuleTable_;
===========================
step 12
step 13
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --mt
===========================
===========================
step 13
step 14
lua ProjectDIR/src/lmod.in.lua bash --regression_testing unload wrapperSh/1.0
===========================
unset LOADEDMODULES;
Expand All @@ -238,12 +242,12 @@ unset -f my_help 2> /dev/null || true;
unset -f save_args 2> /dev/null || true;
[[ -n "${BASH_VERSION:-}" ]] && complete -r xyz123;
===========================
step 14
step 15
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load brokenSh/1.0
===========================
false
===========================
step 15
step 16
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load wrapperSh/1.0
===========================
LOADEDMODULES=wrapperSh/1.0;
Expand Down Expand Up @@ -291,15 +295,15 @@ save_args () {
};
[[ -n "${BASH_VERSION:-}" ]] && complete -F _xyz123 xyz123;
===========================
step 16
step 17
lua ProjectDIR/src/lmod.in.lua bash --regression_testing save
===========================
MODULEPATH=ProjectDIR/rt/sh_to_modulefile/mf;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={wrapperSh={fn="ProjectDIR/rt/sh_to_modulefile/mf/wrapperSh/1.0.lua",fullName="wrapperSh/1.0",loadOrder=1,mcmdT={["ProjectDIR/rt/sh_to_modulefile/second.sh arg1"]={"setenv(\"SECOND\",\"FOO_BAR\")",},["ProjectDIR/rt/sh_to_modulefile/tstScript.sh"]={"setenv(\"MY_NAME\",\"tstScript.sh\")","prepend_path(\"PATH\",\"ProjectDIR/rt/sh_to_modulefile/bin\")","append_path(\"PATH\",\"ProjectDIR/rt/sh_to_modulefile/sbin\")","setenv(\"TST_SCRIPT\",\"1\")","set_alias(\"fooAlias\",\"foobin -q -l\")",[[set_shell_function("banner"," \\ local str=\\"$1\\";\\ local RED='\\033[1;31m';\\ local NONE='\\033[0m';\\ echo \\"${RED}${str}${NONE}\\"\\","")]],[[set_shell_function("fooFunc"," \\ echo \\"arg1: $1\\"\\","")]],[[set_shell_function("junk"," \\ if [ -n \\"${ZSH_VERSION:-}\\" ]; then\\ \\\\echo \\"junk\\";\\ fi\\","")]],[[set_shell_function("my_help"," \\ echo \\"do not forget \\\\\\"foo\\\\\\"\\"\\","")]],[[set_shell_function("save_args"," \\ for arg in \\"$@\\";\\ do\\ printf \\"%s\\\\n\\" \\"$arg\\" | sed -e \\"s/'/'\\\\\\\\\\\\\\\\''/g\\" -e \\"1s/^/'/\\" -e \\"\\\\$s/\\\\$/' \\\\\\\\\\\\\\\\/\\";\\ done;\\ echo \\" \\"\\","")]],"complete(\"bash\",\"XyZ123\",\"-F _xyz123\")",},},propT={},stackDepth=0,status="active",userName="wrapperSh/1.0",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/sh_to_modulefile/mf",},systemBaseMPATH="ProjectDIR/rt/sh_to_modulefile/mf",}';
export _ModuleTable_;
===========================
step 17
step 18
lua ProjectDIR/src/lmod.in.lua bash --regression_testing restore
===========================
MODULEPATH=ProjectDIR/rt/sh_to_modulefile/mf;
Expand Down Expand Up @@ -343,11 +347,11 @@ save_args () {
};
[[ -n "${BASH_VERSION:-}" ]] && complete -F _xyz123 xyz123;
===========================
step 18
step 19
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --mt
===========================
===========================
step 19
step 20
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load A
===========================
LOADEDMODULES=A/1.0;
Expand Down Expand Up @@ -391,7 +395,7 @@ save_args () {
};
[[ -n "${BASH_VERSION:-}" ]] && complete -F _xyz123 xyz123;
===========================
step 20
step 21
lua ProjectDIR/src/lmod.in.lua bash --regression_testing list
===========================
MODULEPATH=OutputDIR/mf;
Expand Down
Loading

0 comments on commit 379bfac

Please sign in to comment.