mirror of
https://github.com/envmodules/modules.git
synced 2026-06-18 00:06:53 +08:00
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.
61 lines
1.7 KiB
Plaintext
61 lines
1.7 KiB
Plaintext
if status -i
|
|
if [ -r @initdir@/fish_completion ]
|
|
source @initdir@/fish_completion
|
|
end
|
|
|
|
# only redirect module from stderr to stdout in interactive mode
|
|
# to avoid breaking non interactive session (scp, sftp, etc)
|
|
function moduleraw
|
|
# use "| source -" rather than "eval" to be able
|
|
# to redirect stderr after stdout being evaluated
|
|
eval @TCLSH@ @libexecdir@/modulecmd.tcl fish $argv | source -
|
|
end
|
|
function module
|
|
moduleraw $argv ^&1
|
|
end
|
|
else
|
|
function module
|
|
eval @TCLSH@ @libexecdir@/modulecmd.tcl fish $argv | source -
|
|
end
|
|
end
|
|
|
|
@setswitchml@# no switchml definition since there is no Fish support in C version
|
|
@setswitchml@
|
|
# setup ENV variables to get module defined in sub-shells (works for 'sh'
|
|
# and 'ksh' in interactive mode and 'sh' (zsh-compat), 'bash' and 'ksh'
|
|
# (zsh-compat) in non-interactive mode.
|
|
set -xg ENV @initdir@/profile.sh
|
|
set -xg BASH_ENV @initdir@/bash
|
|
|
|
set -xg MODULESHOME @prefix@
|
|
|
|
@setbinpath@if not contains @bindir@ $PATH
|
|
@setbinpath@ set -xg PATH @bindir@ $PATH
|
|
@setbinpath@end
|
|
@setbinpath@
|
|
@setmanpath@set manpath (manpath ^/dev/null)
|
|
@setmanpath@if not string match -q '*:@mandir@:*' :$manpath:
|
|
@setmanpath@ if [ -z $manpath ]
|
|
@setmanpath@ set -xg MANPATH @mandir@
|
|
@setmanpath@ else
|
|
@setmanpath@ set -xg MANPATH @mandir@:$manpath
|
|
@setmanpath@ end
|
|
@setmanpath@end
|
|
@setmanpath@
|
|
if not set -q MODULEPATH
|
|
if [ -r @initdir@/.modulespath ]
|
|
set -xg MODULEPATH (sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' \
|
|
@initdir@/.modulespath)
|
|
else
|
|
set -xg MODULEPATH ''
|
|
end
|
|
end
|
|
|
|
if not set -q LOADEDMODULES
|
|
set -xg LOADEDMODULES ''
|
|
end
|
|
|
|
if [ -r @initdir@/modulerc ]
|
|
source @initdir@/modulerc
|
|
end
|