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
This commit is contained in:
Xavier Delaruelle
2023-07-19 17:57:37 +02:00
committed by GitHub
parent ae08b25dac
commit d9fbdfbee9
5 changed files with 95 additions and 44 deletions

View File

@@ -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 %}