From d9fbdfbee930c9bae5c4c007bfb6a844ffdb0744 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Wed, 19 Jul 2023 17:57:37 +0200 Subject: modules: use curly braces to enclose value in Tcl modulefile (#38375) Use curly braces instead of quotes to enclose value or text in Tcl modulefile. Within curly braces Tcl special characters like [, ] or $ are treated verbatim whereas they are evaluated within quotes. Curly braces is Tcl recommended way to enclose verbatim content [1]. Note: if curly braces charaters are used within content, they must be balanced. This point has been checked against current repository and no unbalanced curly braces has been spotted. Fixes #24243 [1] https://wiki.tcl-lang.org/page/Tcl+Minimal+Escaping+Style --- share/spack/templates/modules/modulefile.tcl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'share') diff --git a/share/spack/templates/modules/modulefile.tcl b/share/spack/templates/modules/modulefile.tcl index 52d987da61..746fea2f31 100644 --- a/share/spack/templates/modules/modulefile.tcl +++ b/share/spack/templates/modules/modulefile.tcl @@ -11,16 +11,16 @@ {% block header %} {% if short_description %} -module-whatis "{{ short_description }}" +module-whatis {{ '{' }}{{ short_description }}{{ '}' }} {% endif %} proc ModulesHelp { } { - puts stderr "Name : {{ spec.name }}" - puts stderr "Version: {{ spec.version }}" - puts stderr "Target : {{ spec.target }}" + puts stderr {{ '{' }}Name : {{ spec.name }}{{ '}' }} + puts stderr {{ '{' }}Version: {{ spec.version }}{{ '}' }} + puts stderr {{ '{' }}Target : {{ spec.target }}{{ '}' }} {% if long_description %} - puts stderr "" -{{ long_description| textwrap(72)| quote()| prepend_to_line(' puts stderr ')| join() }} + puts stderr {} +{{ long_description| textwrap(72)| curly_quote()| prepend_to_line(' puts stderr ')| join() }} {% endif %} } {% endblock %} @@ -54,13 +54,13 @@ conflict {{ name }} {% block environment %} {% for command_name, cmd in environment_modifications %} {% if command_name == 'PrependPath' %} -prepend-path --delim "{{ cmd.separator }}" {{ cmd.name }} "{{ cmd.value }}" +prepend-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }} {% elif command_name in ('AppendPath', 'AppendFlagsEnv') %} -append-path --delim "{{ cmd.separator }}" {{ cmd.name }} "{{ cmd.value }}" +append-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }} {% elif command_name in ('RemovePath', 'RemoveFlagsEnv') %} -remove-path --delim "{{ cmd.separator }}" {{ cmd.name }} "{{ cmd.value }}" +remove-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }} {% elif command_name == 'SetEnv' %} -setenv {{ cmd.name }} "{{ cmd.value }}" +setenv {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }} {% elif command_name == 'UnsetEnv' %} unsetenv {{ cmd.name }} {% endif %} @@ -68,7 +68,7 @@ unsetenv {{ cmd.name }} {% endfor %} {# Make sure system man pages are enabled by appending trailing delimiter to MANPATH #} {% if has_manpath_modifications %} -append-path --delim ":" MANPATH "" +append-path --delim {{ '{' }}:{{ '}' }} MANPATH {{ '{' }}{{ '}' }} {% endif %} {% endblock %} -- cgit v1.2.3-60-g2f50