Files
modules/init/fish.in
Xavier Delaruelle 63f5918d4c init: do not load modulerc config is env already set
If MODULEPATH or LOADEDMODULES is already set, do not source the
modulerc configuration file in init scripts.

As a consequence, if .modulespath sets a module path, then modulerc will
be ignored which clarifies how default configuration is loaded: if both
.modulespath and modulerc are defined, .modulespath takes precedence
over modulerc.

So if .modulespath sets a module path, all loaded modules defined in the
modulerc file will be ignored.
2017-03-06 06:09:15 +01:00

63 lines
1.8 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
# load modulerc only if module environment is empty
if [ -r @initdir@/modulerc -a "$MODULEPATH" = '' \
-a "$LOADEDMODULES" = '' ]; then
source @initdir@/modulerc
end