For path-like variable set by sourced script, the newly added path
entries are analyzed to remove duplicates among the same portion to
avoid a path to be prepended multiple times or appended multiple times.
Deduplication does not apply between prepended portion and appended
portion. Path entries found set prior script sourced are also excluded
from deduplication process.
Sourced scripts may detect the need to update PS1, but this decision is
taken over a specific environment where initialization scripts have not
been evaluated for the shells.
sh shell on BSD platform outputs alias definition with different
character escaping than regular sh or dash on Linux platform.
Disable test for this shell on this platform currently. Will see later
on if a need to support this shell is needed.
With quarantine mechanism disabled, no specific IFS is set when
modulecmd.tcl output is evaluated with zsh and ksh shells, sh-to-mod
does not output ';' character at end of each function line, thus when
evaluated with default IFS the multiple lines are treated as a single
command line.
dash has some limitations for this task:
- there is no mechanism to report shell functions set, so no shell
function will be defined or unset with this shell through sh-to-mod
- arguments cannot be passed to a sourced script
Specific code is required to retrieve defined functions in environment
as `typeset -f` may output function definition with no clear separation
between each other.
Redirect stderr onto stdout when sourcing script in sh-to-mod
sub-command in order to avoid a warning message put on stderr by script
were taken as an error by Tcl exec command.
Also mix stdout and stderr messages of script to be able to provide all
of them to user in case an error occurs during script source by shell
(exit code found different than 0).
An error returned by shell execution is reported and ends sh-to-mod
processing.
Add the strTo and listTo procedures to format a string or a list
of string making it compliant with the destination language. Add support
for Tcl and shell output, enclosing strings if they are empty or if they
contain a space character respectively with curly braces or single
quotes. And escaping those character if used in strings.
Use the new procedures in sh-to-mod to enclose/escape script name and
its argument to source in shell command. Also use listTo in reportCmd,
which was previously doing the same enclosing work.
Make use of reportCmd to output result of sh-to-mod sub-command, in
order to get the same formatted output than when doing a module display
(with tabs and colors if enabled).
Add a -nativeargrep argument to reportCmd procedure to use (when called
for sh-to-mod result) Tcl native string representation of list, which
automatically enclose string if needed and escape special characters if
present. Do not make this behavior a default as output made for module
display should not automatically enclose strings using variable value
reference (eg. $VAR).
Add the `sh-to-mod' procedure that executes script with args through
shell and converts environment changes the script performs into
corresponding modulefile commands.
Environment changes made by script are found by making shell first
outputing environment state, then sourcing script and after that
outputing resulting environment state. Shell full output is after this
execution parsed and analyzed, comparing environment state prior script
source with state after script source.
Add support for Bash shell and track changes over environment variables,
shell functions, shell aliases and current working directory.
Result is returned as a list of modulefile commands. Procedure is called
by cmdModuleShToMod which outputs the modulefile commands with modulefile
header '#%Module'.
Transform the startPager procedure into initStateReportfd to have it
automatically called first time value of 'reportfd' state is queried (so
first time a message has to be outputed).
initStateReportfd procedure embeds the output of document start in case
of structured output mode. This output is done there to avoid an
infinite loop of reportfd state initialization.
Initialization of the 'reportfd' state is triggered in initErrorReport
if debug mode is enabled to have its reportDebug calls processed in
buffer mode to get processed in correct order (otherwise reportfd
initialization will appear first, before debug messages stored in
buffer).
'already_report' state is removed as it is now useless.
Transform initPager procedure into initStatePaginate and set this
procedure as the initialization one for the 'paginate' state. Keep a
specific call to 'paginate' state to get it set prior pager
initialization.
'pager_started' state is removed as it is now useless.
Instead of using a specific struct to cache uname properties value, use
global state structure. As a consequence, domainname, kernelversion,
nodename and osversion states are introduced. os state is changed just
to store OS name and not OS name and version: OS version has its own
state now.