summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorXavier Delaruelle <xavier.delaruelle@cea.fr>2023-06-13 10:29:11 +0200
committerGitHub <noreply@github.com>2023-06-13 10:29:11 +0200
commit746eaaf01ac824caa9649b368249b5a6ebdb2311 (patch)
treea4b22c28b424d63e63cf3530df9f5c5b9dbb2490 /share
parentbd2f78ae9a0a27a72e4476c08e2587262e8d8efd (diff)
downloadspack-746eaaf01ac824caa9649b368249b5a6ebdb2311.tar.gz
spack-746eaaf01ac824caa9649b368249b5a6ebdb2311.tar.bz2
spack-746eaaf01ac824caa9649b368249b5a6ebdb2311.tar.xz
spack-746eaaf01ac824caa9649b368249b5a6ebdb2311.zip
modules: append trailing delimiter to MANPATH when set (#36678)
Update modulefile templates to append a trailing delimiter to MANPATH environment variable, if the modulefile sets it. With a trailing delimiter at ends of MANPATH's value, man will search the system man pages after searching the specific paths set. Using append-path/append_path to add this element, the module tool ensures it is appended only once. When modulefile is unloaded, the number of append attempt is decreased, thus the trailing delimiter is removed only if this number equals 0. Disclaimer: no path element should be appended to MANPATH by generated modulefiles. It should always be prepended to ensure this variable's value ends with the trailing delimiter. Fixes #11355.
Diffstat (limited to 'share')
-rw-r--r--share/spack/templates/modules/modulefile.lua4
-rw-r--r--share/spack/templates/modules/modulefile.tcl4
2 files changed, 8 insertions, 0 deletions
diff --git a/share/spack/templates/modules/modulefile.lua b/share/spack/templates/modules/modulefile.lua
index 42ef9e5fd1..f86e76cfe6 100644
--- a/share/spack/templates/modules/modulefile.lua
+++ b/share/spack/templates/modules/modulefile.lua
@@ -84,6 +84,10 @@ setenv("{{ cmd.name }}", "{{ cmd.value }}")
unsetenv("{{ cmd.name }}")
{% endif %}
{% endfor %}
+{# Make sure system man pages are enabled by appending trailing delimiter to MANPATH #}
+{% if has_manpath_modifications %}
+append_path("MANPATH", "", ":")
+{% endif %}
{% endblock %}
{% block footer %}
diff --git a/share/spack/templates/modules/modulefile.tcl b/share/spack/templates/modules/modulefile.tcl
index 935d1df72d..577c40e47c 100644
--- a/share/spack/templates/modules/modulefile.tcl
+++ b/share/spack/templates/modules/modulefile.tcl
@@ -58,6 +58,10 @@ unsetenv {{ cmd.name }}
{% endif %}
{# #}
{% endfor %}
+{# Make sure system man pages are enabled by appending trailing delimiter to MANPATH #}
+{% if has_manpath_modifications %}
+append-path --delim ":" MANPATH ""
+{% endif %}
{% endblock %}
{% block footer %}