Skip to content

Commit c6a72dd

Browse files
committed
doc: desc. bash-eval and --ignore in MIGRATING
1 parent 999a8b5 commit c6a72dd

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

.hunspell.en.dic

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ DesignSync
3939
Deveaud
4040
Diekhans
4141
Dimitri
42+
EOF
4243
EPEL
4344
EnvModEscPS
4445
EnvModEscS
@@ -362,6 +363,7 @@ devel
362363
di
363364
dictionarily
364365
dir
366+
dirname
365367
dirs
366368
dirsym
367369
dirwsym

MIGRATING.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,73 @@ conflicts rather the generic conflict module specification.
316316
:sgrer:`ERROR`: Module cannot be loaded due to a conflict.
317317
HINT: Might try "module unload foo/1" first.
318318
319+
New options for source-sh modulefile command
320+
--------------------------------------------
321+
322+
Support for new *shell* mode named ``bash-eval`` is added to
323+
:mfcmd:`source-sh` modulefile command. With this new mode, the generated
324+
output of the bash shell script is evaluated to get the environment changes
325+
instead of sourcing this script.
326+
327+
.. parsed-literal::
328+
329+
:ps:`$` cat /path/to/modulefiles/foo/foo-output.sh
330+
#!/bin/bash
331+
cat <<EOF
332+
export FOO=value;
333+
alias foo_alias='echo foo_alias;'
334+
foo_function() {
335+
echo foo_function;
336+
}
337+
EOF
338+
:ps:`$` cat /path/to/modulefiles/foo/1
339+
#%Module
340+
set foo_script [file dirname $ModulesCurrentModulefile]/foo-output.sh
341+
:sgrhi:`source-sh bash-eval` $foo_script
342+
343+
:ps:`$` module show foo/1
344+
-------------------------------------------------------------------
345+
:sgrhi:`/path/to/modulefiles/foo/1`:
346+
347+
:sgrcm:`set-alias` foo_alias {echo foo_alias;}
348+
:sgrcm:`set-function` foo_function {
349+
echo foo_function}
350+
:sgrcm:`setenv` FOO value
351+
-------------------------------------------------------------------
352+
:ps:`$` module load foo/1
353+
:ps:`$` foo_alias
354+
foo_alias
355+
356+
``bash-eval`` *shell* support is also available on :subcmd:`sh-to-mod`
357+
sub-command.
358+
359+
A new option is added to :mfcmd:`source-sh` modulefile command: ``--ignore``.
360+
It filters shell elements changed by script, not to get these changes applied
361+
when loading modulefile. This option accepts a list, separated by colon
362+
character, of shell elements: ``envvar``, ``alias``, ``function``,
363+
``complete`` or ``chdir``.
364+
365+
.. parsed-literal::
366+
367+
:ps:`$` module purge
368+
:ps:`$` cat /path/to/modulefiles/foo/2
369+
#%Module
370+
set foo_script [file dirname $ModulesCurrentModulefile]/foo-output.sh
371+
:sgrhi:`source-sh --ignore alias:function bash-eval` $foo_script
372+
373+
:ps:`$` module show foo/2
374+
-------------------------------------------------------------------
375+
:sgrhi:`/path/to/modulefiles/foo/2`:
376+
377+
:sgrcm:`setenv` FOO value
378+
-------------------------------------------------------------------
379+
:ps:`$` module load foo/2
380+
:ps:`$` foo_alias
381+
bash: foo_alias: command not found
382+
383+
This ``--ignore`` option can be used with any *shell* supported by
384+
:mfcmd:`source-sh`.
385+
319386

320387
v5.3
321388
====

0 commit comments

Comments
 (0)