@@ -18,19 +18,19 @@ proc ModulesHelp { } {
1818 puts stderr " Commands include:"
1919 puts stderr " "
2020 puts stderr " - {|module_name|}-run:"
21- puts stderr " singularity run {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container>"
21+ puts stderr " singularity run {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container>"
2222 puts stderr " - {|module_name|}-shell:"
23- puts stderr " singularity shell -s {{ singularity_shell }} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container>"
23+ puts stderr " singularity shell -s {{ singularity_shell }} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container>"
2424 puts stderr " - {|module_name|}-exec:"
25- puts stderr " singularity exec {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container> $*"
25+ puts stderr " singularity exec {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}<container> $*"
2626 puts stderr " - {|module_name|}-inspect-runscript:"
2727 puts stderr " singularity inspect -r <container>"
2828 puts stderr " - {|module_name|}-inspect-deffile:"
2929 puts stderr " singularity inspect -d <container>"
3030 puts stderr " "
3131{% if aliases %}{% for alias in aliases %} puts stderr " - {{ alias.name }}:"
32- puts stderr " singularity exec {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}{% if alias.singularity_options %}{{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %}<container> {{ alias.command | replace(" $" , " \$ " ) }}"
33- {% endfor %}{% else %} puts stderr " - {|module_name|}: singularity run {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %}<container>" {% endif %}
32+ puts stderr " singularity exec {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }} {% endif %}{% if alias.singularity_options %}{{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %}<container> {{ alias.command | replace(" $" , " \$ " ) }}"
33+ {% endfor %}{% else %} puts stderr " - {|module_name|}: singularity run {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %}<container>" {% endif %}
3434 puts stderr " "
3535 puts stderr " For each of the above, you can export:"
3636 puts stderr " "
@@ -66,19 +66,30 @@ conflict {{ name }}
6666setenv SINGULARITY_SHELL {{ singularity_shell }}
6767
6868# interactive shell to any container, plus exec for aliases
69- set shellCmd " singularity \$ {SINGULARITY_OPTS} shell \$ {SINGULARITY_COMMAND_OPTS} -s {{ singularity_shell }} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} ${containerPath} "
70- set execCmd " singularity \$ {SINGULARITY_OPTS} exec \$ {SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} "
71- set runCmd " singularity \$ {SINGULARITY_OPTS} run \$ {SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-- home {{ features.home }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} ${containerPath} "
69+ set shellCmd " singularity \$ {SINGULARITY_OPTS} shell \$ {SINGULARITY_COMMAND_OPTS} -s {{ singularity_shell }} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} ${containerPath} "
70+ set execCmd " singularity \$ {SINGULARITY_OPTS} exec \$ {SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} "
71+ set runCmd " singularity \$ {SINGULARITY_OPTS} run \$ {SINGULARITY_COMMAND_OPTS} {% if features.gpu %}{{ features.gpu }} {% endif %}{% if features.home %}-B {{ features.home | replace( " $ " , " \$ " ) }} -- home {{ features.home | replace( " $ " , " \$ " ) }} {% endif %}{% if features.x11 %}-B {{ features.x11 | replace(" $" , " \$ " ) }} {% endif %}{% if envfile %}-B {{ module_dir }}/{{ envfile }}:/.singularity.d/env/{{ envfile }}{% endif %} {% if bindpaths %}-B {{ bindpaths }}{% endif %} ${containerPath} "
7272set inspectCmd " singularity \$ {SINGULARITY_OPTS} inspect \$ {SINGULARITY_COMMAND_OPTS} "
7373
7474# set_shell_function takes bashStr and cshStr
7575set -alias {|module_name|}-shell " ${shellCmd} "
7676
77-
7877# exec functions to provide "alias" to module commands
79- {% if aliases %}{% for alias in aliases %}
80- set -alias {{ alias.name }} " ${execCmd} {% if alias.singularity_options %} {{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %} ${containerPath} {{ alias.command | replace(" $" , " \$ " ) }}"
81- {% endfor %}{% endif %}
78+ {% if aliases %}
79+ if { [ module-info shell bash ] } {
80+ if { [ module-info mode load ] } {
81+ {% for alias in aliases %} puts stdout " function {{ alias.name }}() { ${execCmd} {% if alias.singularity_options %} {{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %} ${containerPath} {{ alias.command | replace(" $" , " \$ " ) }}; }; export -f {{ alias.name }};"
82+ {% endfor %}
83+ }
84+ if { [ module-info mode remove ] } {
85+ {% for alias in aliases %} puts stdout " unset -f {{ alias.name }};"
86+ {% endfor %}
87+ }
88+ } else {
89+ {% for alias in aliases %} set-alias {{ alias.name }} " ${execCmd} {% if alias.singularity_options %} {{ alias.singularity_options | replace(" $" , " \$ " ) }} {% endif %} ${containerPath} {{ alias.command | replace(" $" , " \$ " ) }}"
90+ {% endfor %}
91+ }
92+ {% endif %}
8293
8394# A customizable exec function
8495set -alias {|module_name|}-exec " ${execCmd} ${containerPath} "
0 commit comments