Skip to content

Commit 75fb304

Browse files
committed
Make "module-info shell" Tcl test compatible with Lmod<=8.7.55
Up to Lmod 8.7.55, the Tcl command "module-info shell" only returns the current shell name and cannot test if a given string corresponds this current shell. A patch is now merged on Lmod, so newer version (8.7.56+) will cope with the "module-info shell bash" syntax. But in the mean time, I propose here to use a test Tcl syntax that will be compatible with both Lmod and Environment Modules: "[module-info shell] eq {bash}". This change may only be of help for people willing to use the Tcl modules produced by SHPC with the Lmod module tool.
1 parent 4bf959f commit 75fb304

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

shpc/main/modules/templates/docker.tcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ set inspectCmd "{{ command }} \${PODMAN_OPTS} inspect ${containerPath}"
8686
{% if wrapper_scripts %}prepend-path PATH ${wrapperDir}/bin{% endif %}
8787

8888
# "aliases" to module commands
89-
{% if aliases %}if { [ module-info shell bash ] } {
89+
{% if aliases %}if { [ module-info shell ] eq {bash} } {
9090
if { [ module-info mode load ] } {
9191
{% for alias in aliases %}{% if alias.name not in wrapper_scripts %} puts stdout "function {{ alias.name }}() { ${execCmd} {% if alias.docker_options %} {{ alias.docker_options | replace("$", "\$") }} {% endif %} --entrypoint {{ alias.entrypoint | replace("$", "\$") }} ${containerPath} {{ alias.args | replace("$", "\$") }} \"\$@\"; }; export -f {{ alias.name }};"{% endif %}
9292
{% endfor %}
@@ -106,14 +106,14 @@ set-alias {|module_name|}-container "echo ${containerPath}"
106106
set-alias {|module_name|}-shell "${shellCmd}"
107107

108108
# A customizable exec function
109-
if { [ module-info shell bash ] } {
109+
if { [ module-info shell ] eq {bash} } {
110110
set-alias {|module_name|}-exec "${execCmd} --entrypoint \"\" ${containerPath} \"\$@\""
111111
} else {
112112
set-alias {|module_name|}-exec "${execCmd} --entrypoint \"\" ${containerPath}"
113113
}
114114

115115
# Always provide a container run
116-
if { [ module-info shell bash ] } {
116+
if { [ module-info shell ] eq {bash} } {
117117
set-alias {|module_name|}-run "${runCmd} \"\$@\""
118118
} else {
119119
set-alias {|module_name|}-run "${runCmd}"

shpc/main/modules/templates/singularity.tcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ set inspectCmd "singularity \${SINGULARITY_OPTS} inspect \${SINGULARITY_COMMAND_
9292
{% if wrapper_scripts %}prepend-path PATH ${wrapperDir}/bin{% endif %}
9393

9494
# "aliases" to module commands
95-
{% if aliases %}if { [ module-info shell bash ] } {
95+
{% if aliases %}if { [ module-info shell ] eq {bash} } {
9696
if { [ module-info mode load ] } {
9797
{% for alias in aliases %} {% if alias.name not in wrapper_scripts %} puts stdout "function {{ alias.name }}() { ${execCmd} {% if alias.singularity_options %} {{ alias.singularity_options | replace("$", "\$") }} {% endif %} ${containerPath} {{ alias.command | replace("$", "\$") }} \"\$@\"; }; export -f {{ alias.name }};"{% endif %}
9898
{% endfor %}
@@ -111,14 +111,14 @@ set-alias {|module_name|}-shell "${shellCmd}"
111111
set-alias {|module_name|}-container "echo ${containerPath}"
112112

113113

114-
if { [ module-info shell bash ] } {
114+
if { [ module-info shell ] eq {bash} } {
115115
set-alias {|module_name|}-exec "${execCmd} ${containerPath} \"\$@\""
116116
} else {
117117
set-alias {|module_name|}-exec "${execCmd} ${containerPath}"
118118
}
119119

120120
# Always provide a container run
121-
if { [ module-info shell bash ] } {
121+
if { [ module-info shell ] eq {bash} } {
122122
set-alias {|module_name|}-run "${runCmd} \"\$@\""
123123
} else {
124124
set-alias {|module_name|}-run "${runCmd}"

0 commit comments

Comments
 (0)