Some variables, that were unquoted intentionally were converted to arrays.
According to ShellCheck's documentation:
Quoting variables prevents word splitting and glob expansion, and prevents
the script from breaking when input contains spaces, line feeds, glob
characters and such.
Related: https://www.shellcheck.net/wiki/SC2086
Related: #470
According to ShellCheck's documentation:
-a and -o in [ .. ] test expressions are not well defined, and can cause
incorrect results when arguments start with dashes or contain !.
Related: https://www.shellcheck.net/wiki/SC2166
Related: #470
According to ShellCheck's documentation:
Different shells support different features. To give effective advice,
ShellCheck needs to know which shell your script is going to run on.
Related: https://www.shellcheck.net/wiki/SC2148
Related: #470
Update initialization, profile and completion scripts to enclose all
references to the installation paths.
Enclosing modulecmd.tcl installation path this way is not effective with
the quarantine mechanism that implies a double shell code evaluation. So
it is advised not to install Modules in a path containing a whitespace
character if the quarantine mechanism is needed.
Add MANPATH setup in autoinit command instead of shell initialization
scripts. Use this way one modulecmd.tcl internal code instead of shell
code for every shell requiring to setup MANPATH with Modules binaries
location (sh, bash, ksh, zsh, csh, tcsh, fish).
Fixes#462.
Add PATH setup in autoinit command instead of shell initialization
scripts. Use this way one modulecmd.tcl internal code instead of shell
code for every shell requiring to setup PATH with Modules binaries
location (sh, bash, ksh, zsh, csh, tcsh, fish).
Fixes#462.
Introduce the __MODULES_QUARANTINE_SET environment variable to put back
when starting modulecmd.tcl run the environment set on hold by
initialization script (for autoinit calls) or by module shell function
(for regular calls).
This new environment variable is tested to apply quarantine unhold
mechanism instead of checking if the run_quarantine configuration option
is set and shell accurately supports the mecanishm. With this change it
is possible to enable or disable the quarantine support at module
initialization time (through initrc configuration file) instead of
freezing this configuration when building the modulecmd.tcl script.
Rename the environment variables used to indirectly pass to
`modulecmd.tcl` the value of variables set in quarantine (variables
whose name finishes with `_modquar`). A `__MODULES_QUAR_` prefix is
applied to the name of these variables instead of the `_modquar` suffix
to indicate they are intended for Modules internal use of only.
When initializing module on ksh shell with the autoinit sub-command, add
to the FPATH environment variable the directory where module function is
defined. Which helps to get module function defined in ksh interactive
and non-interactive sub-shells.
This FPATH setup for ksh shell was previously done in ksh initialization
script.
Take into account Modules initialization configurations found in ``etc``
directory if they exist rather in ``init`` directory. If ``initrc``
configuration file is found in ``etcdir`` then it is preferred over
``modulerc`` file in ``initdir``. Following the same trend,
``modulespath`` configuration file is found in ``etcdir`` then it is
preferred over ``.modulespath`` file in ``initdir``.
Introduce the ability not to set the shell startup file that ensure
``module`` command is defined once shell has been initialized. Setting
shell startup file currently means defining ``ENV`` and ``BASH_ENV``
environment variable to the Modules bourne shell initialization script.
``./configure`` options ``--enable-set-shell-startup`` and
``--disable-set-shell-startup`` define if shell startup should be set or
not by default. It could be superseded with the
``MODULES_SET_SHELL_STARTUP`` environment variable, that could be set
with ``config`` module sub-command through the ``set_shell_startup``
option.
Improve readability of variable definition operations by writing one
definition operation per line rather having multiple commands on a single
line like 'VAR=val; export VAR'.
Fixes#225.
In shell initialization scripts, initialize MANPATH if not set with a
value that preserves manpath system configuration even after addition
of paths to this variable by modulefiles
Fixes#224
Add the ability to control whether or not code to support quarantine
mechanism should be added to the module function and initialization
scripts. Enabled by default
Fixes#167
Add the ability to control whether or not code to support silent shell
debug should be added to the module function and sh-kind initialization
scripts. Enabled by default
Fixes#166
To get coherent with the test made by modulecmd.tcl to determine if
autoinit sub-command has to produce code for the '_module_raw' shell
function, export this function (or initialize it on compat mode) if
stderr is attached to a terminal.
Was previously testing stdout, whereas modulecmd.tcl is checking stderr,
which led to inconsistencies as described in [1].
Fixes#169
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1575479
Add the ability to append rather prepend the man or bin directory when
adding these directory to the relative environment variable is enabled
(with --enable-set-manpath or --enable-set-binpath).
Takes the form of 2 new configure options: --enable-append-manpath and
--enable-append-binpath. No effect if set but relative
--enable-set-{bin,man}path option is unset or disabled.
Quote autoinit result for eval interpretation on SH-kind shells to
avoid parameter expansion to randomly occur on generated code
depending on file or directory names of current working directory.
Test basic module commands in install testsuite with a
'something (test)' file existing in current working directory.
Fixes bug reported at [1].
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1549664
To avoid unbound variables on bash '-eu' mode for instance, use a
default value on undefined variable. Adapt SH init scripts and autoinit
code.
Add 'bash -eu' to the list of tested shells on 'testinstall' suite.
Fixes#151
Adapt the 'string contains' tests in ksh init script (used to setup
FPATH, PATH and MANPATH without duplicates) to correctly handle paths
containing '+' character, which is detected as a pattern-specific
character on the '=~' test condition previously used.
Introduce MODULES_SILENT_SHELL_DEBUG environment variable to silent the
xtrace and verbose output on sh-kind shells.
When set (means MODULES_SILENT_SHELL_DEBUG=1), current xtrace and
verbose flags are saved then these shell properties are disabled. Once
execution is finished, saved setup is restored.
This mechanism is defined on initialization scripts, at the beginning to
silent, at the end to restore defined behavior. It is also defined
within the module function following exact same principle.
By default, xtrace and verbose shell properties are applied to module
function and initialization script if enabled in calling shell script or
interactive session. These properties are disabled in module context only
if MODULES_SILENT_SHELL_DEBUG is set to '1'.
Notice that if xtrace/verbose properties are set, shell code that
leads to disable them when MODULES_SILENT_SHELL_DEBUG is set will be
outputed as debugging is set during these operations.
The mechanism only applies to the SH-shell family.
Closes#121
Add --with-quarantine-vars configure option to define quarantine
mechanism configuration at build time.
Value passed to the configure option will be used by Makefile to
initialize in the various initialization scripts the
MODULES_RUN_QUARANTINE variable and eventual MODULES_RUNENV_<VAR>.
With quarantine mechanism sh-kind init scripts or module function are
sensitive to IFS value. If space character is not part of IFS, eval
command will not be able to understand command-line string.
This commit add code in init scripts and module function to guaranty
correct value for IFS.
Test that the names of the environment variable defined in
MODULES_RUN_QUARANTINE are valid names.
Add test in quarantine setup code within init scripts (silent check) and
also test in modulecmd.tcl. The latter reports a warning if a bad name
is detected.
Add a non-regression test in modules.00-init and install.00-init test
suites.
As now a call to modulecmd.tcl defines the module function and
surrounding initial environment, this execution should also be shield
against bad environment with quarantine mechanism.
Make use of autoinit module command to initialize module command and its
initial surrounding environment (default value for MODULESHOME,
MODULEPATH, LOADEDMODULES and parse of init/.modulespath).
Then if compatibility version is currently activated redefined the
module command to point to the compat binary. But the compat version
will benefit from the surrounding environment initialization made by
autoinit.
With this change, activated compatibility version will also get its
environment initialized by the init/modulerc file whereas before this
change only the main version was affected by this setup file.
Change from previous behavior where redirection were set if shell was
interactive. With this change, a 'sh script' command launched from a
terminal session will setup module stderr redirection whereas previously
it was not the case as script was not ran in interactive mode.
Shell interactive mode is useful to know that interaction will occur on
stdin (interesting for completion setup). Knowing session is attached to
a terminal seems to be the good pivot to adapt stdout or stderr
functioning (help to determine if PAGER mode can be enabled or not on
'git')
Introduce MODULE_USE_COMPAT_VERSION environment variable to control the
activation of the compatibility version rather main version in case of
--enable-compat-version installation.
The initialization script of the shells supporting compatibility version
are adapted to define the 'module' command based on the modulecmd-compat
binary if MODULE_USE_COMPAT_VERSION is set to 1. Elsewhere module is
based on modulecmd.tcl.
'switchml' function of alias is reintroduced to switch between main and
compatibility version based on the state of the
MODULE_USE_COMPAT_VERSION environment variable.
Acknowledgment: this development has been made and funded within the
framework of the PRACE Fifth Implementation Phase (PRACE-5IP) project
(http://www.prace-ri.eu/). PRACE-5IP receives funding from the EU's
Horizon 2020 research and innovation programme (2014-2020) under grant
agreement no. 730913.
Remove the --enable-set-switchml, --enable-use-cver-dotmodulespath,
--with-cver-initdir, --with-cver-bindir and --with-cver-mandir configure
option that previously enabled to link Modules-Tcl installation to an
external Modules-C installation.
This change is an initial step toward a bundled installation of Tcl/C
versions, so the external linking support will transform into a dual
flavor installation.
If MODULEPATH or LOADEDMODULES is already set, do not source the
modulerc configuration file in init scripts.
As a consequence, if .modulespath sets a module path, then modulerc will
be ignored which clarifies how default configuration is loaded: if both
.modulespath and modulerc are defined, .modulespath takes precedence
over modulerc.
So if .modulespath sets a module path, all loaded modules defined in the
modulerc file will be ignored.
Introduce 'switchml' tool, a shell function (or alias for csh or tcsh
shells) that swap currently enabled Modules version (C or Tcl) by the
other version (C or Tcl).
In case a swapped version was defining specific PATH or MANPATH entries,
these specific entries are removed when switching to the other version
to avoid still relying on the binaries and man pages of the swapped-out
version.
Add the possibility to set PATH and MANPATH in shell init scripts
(sh-like, csh-like and fish scripts) if specific option are enabled in
makefile (enabled by default). With this, bin directory and man
directory of the modules-tcl installation are prepended to the MANPATH
and PATH environment variables.
Prepending is required for PATH as manpath utility in its default Linux
setup will automatically set MANPATH from PATH change, so if we want
MANPATH to be prepended, PATH has to be prepended.