Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty line in set_shell_function() results in Bash syntax error #748

Open
kcgthb opened this issue Feb 11, 2025 · 1 comment
Open

Empty line in set_shell_function() results in Bash syntax error #748

kcgthb opened this issue Feb 11, 2025 · 1 comment

Comments

@kcgthb
Copy link
Contributor

kcgthb commented Feb 11, 2025

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:

  1. create a test module with:
$ cat test/01.lua
local _func = [==[

    echo foo

]==]

set_shell_function("foo", _func)
  1. 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
@rtmclay
Copy link
Member

rtmclay commented Feb 19, 2025

I was able to reproduce the issue and devised a solution. The only thing I can do is remove blank lines from the function definition. Anything else is crazy. For example having a module like:

   local _func = [==[
    STR="
    foo
    bar
"
    echo $STR \





]==]

set_shell_function("foo", _func)

will affect the string definition if I try to add "" to the end of each line.

Please try branch IS748-shFunc to see if it works for you. Thanks very much for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants