diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2019-07-15 22:43:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-15 22:43:53 -0700 |
commit | 3f47c5967d227dc58a71a4053889b5b31764444d (patch) | |
tree | 3b995620f1a995f177b2e434e6f8d50ca43c01ac | |
parent | ce88cc75ef70bf2663e805c9595850b5c02e99d7 (diff) | |
download | spack-3f47c5967d227dc58a71a4053889b5b31764444d.tar.gz spack-3f47c5967d227dc58a71a4053889b5b31764444d.tar.bz2 spack-3f47c5967d227dc58a71a4053889b5b31764444d.tar.xz spack-3f47c5967d227dc58a71a4053889b5b31764444d.zip |
bugfix: fix module() function in setup-env.sh (#12030)
Modify `setup-env.sh` to export fewer variables but to still set the module() function correctly.
-rwxr-xr-x | share/spack/setup-env.sh | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh index 9425d0b379..ae6d00a47b 100755 --- a/share/spack/setup-env.sh +++ b/share/spack/setup-env.sh @@ -324,14 +324,17 @@ if [ "${need_module}" = "yes" ]; then if [ "${_sp_module_prefix}" != "not_installed" ]; then # activate it! # environment-modules@4: has a bin directory inside its prefix - MODULE_PREFIX_BIN="${_sp_module_prefix}/bin" - if [ ! -d "${MODULE_PREFIX_BIN}" ]; then + _sp_module_bin="${_sp_module_prefix}/bin" + if [ ! -d "${_sp_module_bin}" ]; then # environment-modules@3 has a nested bin directory - MODULE_PREFIX_BIN="${_sp_module_prefix}/Modules/bin" + _sp_module_bin="${_sp_module_prefix}/Modules/bin" fi - export MODULE_PREFIX_BIN - _spack_pathadd PATH "${MODULE_PREFIX_BIN}" - module() { eval `${MODULE_PREFIX_BIN}/modulecmd ${_sp_shell} $*`; } + + # _sp_module_bin and _sp_shell are evaluated here; the quoted + # eval statement and $* are deferred. + _sp_cmd="module() { eval \`${_sp_module_bin}/modulecmd ${_sp_shell} \$*\`; }" + eval "$_sp_cmd" + _spack_pathadd PATH "${_sp_module_bin}" fi; else eval `spack --print-shell-vars sh` |