modules: no --delim option if separator is colon character (#39010)

Update Tcl modulefile template to simplify generated `append-path`,
`prepend-path` and `remove-path` commands and improve their readability.

If path element delimiter is colon character, do not set the `--delim`
option as it is the default delimiter value.
This commit is contained in:
Xavier Delaruelle
2023-10-26 15:55:49 +02:00
committed by GitHub
parent f57c2501a3
commit 751b64cbcd
2 changed files with 23 additions and 25 deletions

View File

@@ -54,11 +54,23 @@ conflict {{ name }}
{% block environment %}
{% for command_name, cmd in environment_modifications %}
{% if command_name == 'PrependPath' %}
{% if cmd.separator == ':' %}
prepend-path {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
{% else %}
prepend-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
{% endif %}
{% elif command_name in ('AppendPath', 'AppendFlagsEnv') %}
{% if cmd.separator == ':' %}
append-path {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
{% else %}
append-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
{% endif %}
{% elif command_name in ('RemovePath', 'RemoveFlagsEnv') %}
{% if cmd.separator == ':' %}
remove-path {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
{% else %}
remove-path --delim {{ '{' }}{{ cmd.separator }}{{ '}' }} {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
{% endif %}
{% elif command_name == 'SetEnv' %}
setenv {{ cmd.name }} {{ '{' }}{{ cmd.value }}{{ '}' }}
{% elif command_name == 'UnsetEnv' %}
@@ -68,7 +80,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 MANPATH {{ '{' }}{{ '}' }}
{% endif %}
{% endblock %}