Closed
Description
Describe the bug
Having an empty line at then end of a Lua multi-line variable used in set_shell_function()
results in a syntax error while loading the module:
bash: syntax error near unexpected token `;'
To Reproduce
Steps to reproduce the behavior:
- create a test module with:
$ cat test/01.lua
local _func = [==[
echo foo
]==]
set_shell_function("foo", _func)
- load the module:
$ ml test/01
bash: syntax error near unexpected token `;'
Workaround: removing the empty line after echo foo
in the multi-line Lua variable doesn't generate the syntax error message. Escaping the last line works as well:
local _func = [==[
echo foo \
]==]
doesn't generate the shell syntax error when loading the module.
Expected behavior
No syntax error when loading the module.
Desktop (please complete the following information):
- OS: Linux
- Linux distribution: CentOS
- Lmod Version: 8.7.55
- For Lmod Versions 8.7.7+, please run "module --miniConfig" and
include the output here.
$ module --miniConfig
Modules based on Lua: Version 8.7.55 [branch: (detached from 8.7.55)] 2025-02-10 15:54 -08:00
by Robert McLay [email protected]
Lmod Version: 8.7.55
Lua Version: 5.1
MODULEPATH: /share/software/modules/staging:/share/software/modules/math:/share/software/modules/devel:/share/software/modules/categories
Changes from Default Configuration
----------------------------------
Name Where Set Default Value
---- --------- ------- -----
LFS_VERSION D 1.6.3 1.8.0
LMOD_ADMIN_FILE E /share/software/user/open/lmod/etc/admin.list /share/software/modules/admin.list
LMOD_AVAIL_STYLE E <system> categories
LMOD_BRANCH D main (detached from 8.7.55)
LMOD_FAST_TCL_INTERP C yes no
LMOD_MODULERC E /share/software/user/open/lmod/etc/rc /share/software/modules/.modulerc.lua
LMOD_PACKAGE_PATH D nil /share/software/modules/
LMOD_PAGER C less /bin/less
LMOD_RC E /share/software/modules/lmodrc.lua
LMOD_REDIRECT E no yes
LMOD_SITEPACKAGE_LOCATION Other /share/software/user/open/lmod/8.7.55/libexec/SitePackage.lua /share/software/modules/SitePackage.lua
LMOD_SITE_NAME C false sherlock
LMOD_SYSHOST E false sherlock
LMOD_SYSTEM_DEFAULT_MODULES E __unknown__ devel,math
LMOD_TCLSH C tclsh /bin/tclsh
LMOD_USING_FAST_TCL_INTERP Other yes no
MODULEPATH_ROOT E /share/software/modules
PATH_TO_LUA C lua /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
Metadata
Metadata
Assignees
Labels
No labels