Apply on auto-generated autoinit code for sh-kind shells the same
changes than initialization scripts to fix the SC2166 and SC2086 issues
reported by ShellCheck linter.
Autoinit generated code is thus kept in line with initialization script
code.
According to ShellCheck's documentation:
export takes a variable name, but ShellCheck has noticed that you give it
an expanded variable instead. Remove $/${} for that, or use ${var?} to quiet.
Related: https://www.shellcheck.net/wiki/SC2163
Related: #470
According to ShellCheck's documentation:
When command expansions are unquoted, word splitting and globbing will occur.
This often manifests itself by breaking when filenames contain spaces.
Related: https://www.shellcheck.net/wiki/SC2046
Related: #470
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:
In the original code, the return value of mycmd in $(mycmd) is ignored,
and export will instead always return true. This may prevent conditionals,
set -e and traps from working correctly.
Related: https://www.shellcheck.net/wiki/SC2155
Related: #470
These occurrences do not cause any problems described below but it's better
to be verbose that we indeed want to access the first array element.
According to ShellCheck's documentation:
When referencing arrays, $myarray is equivalent to ${myarray[0]} --
it results in only the first of multiple elements.
Related: https://www.shellcheck.net/wiki/SC2128
Related: #470
According to ShellCheck's documentation:
Use "$@" (with quotes) to prevent whitespace problems. $* and ${array[*]},
unquoted, is subject to word splitting and globbing.
Related: https://www.shellcheck.net/wiki/SC2048
Related: #470
These occurrences do not seem to cause any problems described below but
let's still fix it for the sake of consistency within this script.
According to ShellCheck's documentation:
ShellCheck noticed that you have used a variable as an array, but then assign
it a string. array=foo is equivalent to array[0]=foo, and leaves the rest
of the elements unaffected.
Related: https://www.shellcheck.net/wiki/SC2178
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:
Bourne shells are very whitespace sensitive. Adding or removing spaces can
drastically alter the meaning of a script.
Related: https://www.shellcheck.net/wiki/SC1035
Related: #470
According to ShellCheck's documentation:
Double quotes around $@ and ${array[@]}) prevent globbing and word splitting
of individual elements, while still expanding to multiple separate arguments.
Related: https://www.shellcheck.net/wiki/SC2068
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 mb script to skip several releases and be able to run bench or
profiling on old and recent releases. Versions 4.1, 4.3, 4.5, 4.7 and
5.1 are retained for bench mode. 4.5, 4.7 and 5.1 are retained for
profile mode.
Allow the unload of sticky modules when restoring collection. Goal is to
be able to restore designated collection as it was saved, thus without
the loaded sticky modules. If such collections were saved without the
sticky modules in it, it means that these sticky modules can safely be
unloaded when moving to the collection state.
As a result, using the --force option is of no use for restore
sub-command.
This change does not impact super-sticky modules. Such modules cannot be
unloaded during a restore, even if forced.
With this change, behavior of restore sub-command with sticky modules is
aligned with Lmod.