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

configure script doesn't work on dash-only systems #741

Open
bedroge opened this issue Dec 23, 2024 · 2 comments
Open

configure script doesn't work on dash-only systems #741

bedroge opened this issue Dec 23, 2024 · 2 comments

Comments

@bedroge
Copy link

bedroge commented Dec 23, 2024

Describe the bug
While bumping the Lmod version in Gentoo (gentoo/gentoo#39798), it was reported that the configure script fails for a few people (also see https://bugs.gentoo.org/890939) who use dash for /bin/sh. It seems there are some dash-incompatible checks (e.g. https://github.com/TACC/Lmod/blob/main/configure#L4438 and https://github.com/TACC/Lmod/blob/main/configure#L4462, where the substring expansion is not supported on dash, but there are more).

I tried to reproduce this, and it seems like it only happens on systems with /bin/sh -> dash and which don't have bash at all (otherwise configure is picking up bash anyway?). That made me wonder if dash-only is supposed to be supported by Lmod? If not, maybe it would be nice if it could detect this and fail with a clear error message? If it is supported, some checks need to be changed to something that is supported by dash.

To Reproduce
Steps to reproduce the behavior:

Run ./configure on a system without bash installed, and with /bin/sh -> dash. This is a small reproducer that shows why it breaks in this case:

$ cat substring.sh
#!/bin/sh
PATH_TO_LUA=/some/path
#echo ${PATH_TO_LUA:0:1}
$ ./substring.sh
./substring.sh: 3: Bad substitution

Expected behavior
The ./configure script completes without errors or gives a clear error about dash-only not being supported.

Desktop (please complete the following information):

  • OS: Linux
  • Linux distribution: Gentoo/Ubuntu
  • Lmod Version: 8.7.55
@bedroge
Copy link
Author

bedroge commented Dec 23, 2024

I tried to change the lines that do not work for dash, and then the configure script does complete. The make install still failed because the proj_mgmt/convert_mode.sh and proj_mgmt/DATE_cmd.sh had a /bin/bash shebang, but changing that to /bin/sh solved it. The installation completed without issues and seems to work fine.

@bedroge
Copy link
Author

bedroge commented Dec 24, 2024

This is a full diff of my configure (where I chose a printf solution to get the first character, https://stackoverflow.com/questions/27791251/get-first-character-of-a-string-shell has quite a few other ones) and the original one:

# diff configure.orig configure.new
4438c4438
<     if test ${PATH_TO_LUA:0:1} != '/' ; then
---
>     if test $(printf %.1s "$PATH_TO_LUA") != '/' ; then
4462c4462
<     if test ${PATH_TO_LUAC:0:1} != '/' ; then
---
>     if test $(printf %.1s "$PATH_TO_LUAC") != '/' ; then
4738c4738
< if test $MODE == "user_default" ; then
---
> if test $MODE = "user_default" ; then
5405,5406c5405
< 
< if ! command -v $PATH_TO_LUA &>/dev/null ; then
---
> if ! (command -v $PATH_TO_LUA >/dev/null 2>&1) ; then
5413c5412
<    if test "${PATH_TO_LUA:0:1}" = '/' -o "${PATH_TO_LUAC:0:1}" = '/'; then
---
>    if test $(printf %.1s "$PATH_TO_LUA") = '/' -o $(printf %.1s "$PATH_TO_LUA") = '/'; then
5423c5422
<    if test "${PATH_TO_LUA:0:1}" = '/' -a "${PATH_TO_LUAC:0:1}" != '/'; then
---
>    if test $(printf %.1s "$PATH_TO_LUA") = '/' -a $(printf %.1s "$PATH_TO_LUA") != '/'; then
5426c5425
<    if test "${PATH_TO_LUA:0:1}" != '/' -a "${PATH_TO_LUAC:0:1}" = '/'; then
---
>    if test $(printf %.1s "$PATH_TO_LUA") != '/' -a $(printf %.1s "$PATH_TO_LUA") = '/'; then
5436c5435
< if ! command -v $PATH_TO_LUA &>/dev/null ; then
---
> if ! (command -v $PATH_TO_LUA >/dev/null 2>&1) ; then
5442c5441
< if test ${PATH_TO_LUA:0:1} != '/' ; then
---
> if test $(printf %.1s "$PATH_TO_LUA") != '/' ; then
5491c5490
< if ! command -v $PATH_TO_LUAC &>/dev/null ; then
---
> if ! (command -v $PATH_TO_LUAC >/dev/null 2>&1) ; then
5497c5496
< if test "${PATH_TO_LUAC:0:1}" != '/' ; then
---
> if test $(printf %.1s "$PATH_TO_LUA") != '/' ; then
5592c5591
<   if ! $PATH_TO_LUA $ac_confdir/proj_mgmt/luaModuleAvailable $i 2> /dev/null ; then
---
>   if ! ($PATH_TO_LUA $ac_confdir/proj_mgmt/luaModuleAvailable $i >/dev/null) ; then

@bedroge bedroge changed the title configure script fails with Bad substitution for dash shells configure script doesn't work on dash-only systems Dec 24, 2024
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

1 participant