Commit Graph

19 Commits

Author SHA1 Message Date
Xavier Delaruelle
5b4831873e Args after var name are values on {append,prepend,remove}-path
Fix argument parsing for the `append-path`, `prepend-path` and
`remove-path` modulefile commands to consider every arguments found
after the variable name as variable values and not command option even
if argument starts with `-` character.

Fixes #278.
2019-06-28 21:42:58 +02:00
Xavier Delaruelle
84ed76fa4f Raise error when bad option passed to {append,prepend,remove}-path
Raise an error when an invalid option is set on append-path,
prepend-path or remove-path modulefile command.

Fixes #249.
2019-04-25 18:54:27 +02:00
Xavier Delaruelle
46ffd34f0d Make append/prepend-path alter ::env() on display/help/test/whatis modes
Like previously done for 'setenv', set the variable passed to
'append-path' and 'prepend-path' procedures in ::env() array to make it
available for later use during the modulefile evaluation.

As a side effect as append-path/prepend-path commands are now evaluated
on help, test, display and whatis modes, invalid argument on these
commands will raise error. Previously arguments were not parsed so no
error raised.

Add 50-cmds/049-append-env and 50-cmds/059-prepend-env tests to check
this ::env() array change over all evaluation mode. Adapt
50-cmds/350-allin to check this change against 'whatis' mode.
2018-04-08 08:42:04 +02:00
Xavier Delaruelle
02cfadf969 testsuite: bad ref counter tests in 50-cmds/040-append 2018-02-26 19:01:13 +01:00
Xavier Delaruelle
1601b670fb testsuite: large val append test in 50-cmds/040-append 2018-02-25 20:57:06 +01:00
Xavier Delaruelle
3fcc9b46e7 Add --index opt to remove-path
Remove path entry in environment variable by passing an index rather a
string. String at specified index in content list is removed if coherent
with relative reference counter.
2017-12-21 05:43:13 +01:00
Xavier Delaruelle
b2105b8834 Introduce --duplicates opt to {append,prepend}-path
Let the possibility to append or prepend path element entry to a
variable even if this entry is already registered into the variable
which introduces duplicates element within the variable value.

Entries are added with eventual duplication by the use of the
--duplicate option on append-path and prepend-path commands. These
additions increment the reference counter as usual.

Removal of duplicated path entry depends on the reference counter value.
Entries are not removed unless reference counter value is lesser than
the number of duplicated entries.
2017-12-19 21:34:52 +01:00
Xavier Delaruelle
8c4b3b745d Pass multi paths in multi strs on {append,prepend,remove}-path
Enable append-path, prepend-path and remove-path to receive multiple
path value arguments.

Add some non-regression tests for modulefile or sub-command cases.

Update modulefile.4 and module.1 docs.

Closes #141
2017-12-19 06:53:50 +01:00
Xavier Delaruelle
f13fac6235 Pass multiple paths in 1 str on {append,prepend,remove}-path
Detect if path string passed to append-path, prepend-path or remove-path
commands is composed of multiple path entries (separated by specified or
default delimiter string). In this situation add/remove each path
separately to correctly update relative reference counter.

Add some non-regression tests for modulefile or sub-command cases.

Update modulefile.4 doc.

Closes #142
2017-12-17 16:20:52 +01:00
Xavier Delaruelle
09841ad704 Check env var name not empty for *-path commands 2017-12-15 07:24:07 +01:00
Xavier Delaruelle
ccf69b3144 Improve {append,prepend,remove}-path arg check
Detect missing environment variable name or value when calling
append-path, prepend-path or remove-path procedures. Raise error in this
situation.

Introduce a 'parsePathCommandArgs' to check args for the 3 *-path
commands.

Add non-regression tests in 050-cmds and 070-maint suites to check bad
argument situations.

Closes #139
2017-12-15 06:35:18 +01:00
Xavier Delaruelle
457405fa64 Make 'switch' command handle a single argument
On a 'module switch [mod1] mod2', If 'mod1' is not specified, then it is
assumed to be the currently loaded module with the same root name as
'mod2'.

Introduce a 'getLoadedWithClosestName' procedure to look at currently
loaded modules and return the one with the closest name to the name
passed as argument.

Import and adapt 170-swap, 172-swap-app-delim, 173-swap-app-delim,
175-swap2, 177-swap-prep-delim and 178-swap-prep-delim tests to the
50-cmds suite.
2017-01-04 08:58:12 -06:00
Kent Mein
bd4a515a7d Moved things out of the tcl directory.
Kent
2013-01-10 15:48:30 -06:00
Kent Mein
76adb1c7e3 Removed all of the non tcl version stuff. Or most of it anyway.
Kent
2013-01-10 15:44:49 -06:00
R.K. Owen
5ce0bbfd75 Rolled in the fix by Tyson Whitehead for the "module swap" with the
--delim option
2012-10-30 14:00:17 -07:00
rkowen
751c46263c Rolled in the 3.2.7 changes so far. 2008-02-20 06:21:37 +00:00
rkowen
26653fabe6 Rolled in the 3.2.3 prepend-path/append-path --delim changes. 2006-06-01 19:56:43 +00:00
rkowen
9f8cb87369 Rolled in the xstrtok changes and tests from modules-3-2-2. 2006-05-01 14:52:19 +00:00
rk
e816ab15b5 modules is a shell tool for setting-up the user environment on the
fly, as it were.  It's a powerful mechanism for dynamically changing
environment variables, aliases, X11 resources, etc.
It uses an embedded Tcl intrepretor, with a few extensions.  Therefore,
it has a well defined language syntax.
Version 3.1 is GPL, and includes many improvements over the 3.0beta.
2000-06-28 00:17:34 +00:00