From 746eaaf01ac824caa9649b368249b5a6ebdb2311 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Tue, 13 Jun 2023 10:29:11 +0200 Subject: 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. --- share/spack/templates/modules/modulefile.lua | 4 ++++ share/spack/templates/modules/modulefile.tcl | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'share') 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 %} -- cgit v1.2.3-70-g09d2