diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2020-07-05 22:35:01 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2020-07-06 13:55:14 -0700 |
commit | c00a05bfba50b79ce865ce32385d782667abea3d (patch) | |
tree | 4e541bed7b895c796c3e197ba1619b0e164b07c1 /share/spack/setup-env.fish | |
parent | 9ec9327f5aacc7b62a1469771c8917547393676d (diff) | |
download | spack-c00a05bfba50b79ce865ce32385d782667abea3d.tar.gz spack-c00a05bfba50b79ce865ce32385d782667abea3d.tar.bz2 spack-c00a05bfba50b79ce865ce32385d782667abea3d.tar.xz spack-c00a05bfba50b79ce865ce32385d782667abea3d.zip |
bugfix: no infinite recursion in setup-env.sh on Cray
On Cray platforms, we rely heavily on the module system to figure out
what targets, compilers, etc. are available. This unfortunately means
that we shell out to the `module` command as part of platform
initialization.
Because we run subcommands in a shell, we can get infinite recursion if
`setup-env.sh` and friends are in some init script like `.bashrc`.
This fixes the infinite loop by adding guards around `setup-env.sh`,
`setup-env.csh`, and `setup-env.fish`, to prevent recursive
initializations of Spack. This is safe because Spack never shells out to
itself, so we do not need it to be initialized in subshells.
- [x] add recursion guard around `setup-env.sh`
- [x] add recursion guard around `setup-env.csh`
- [x] add recursion guard around `setup-env.fish`
Diffstat (limited to 'share/spack/setup-env.fish')
-rwxr-xr-x | share/spack/setup-env.fish | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/share/spack/setup-env.fish b/share/spack/setup-env.fish index a534f09ee9..dd2a17f74f 100755 --- a/share/spack/setup-env.fish +++ b/share/spack/setup-env.fish @@ -36,6 +36,12 @@ # to come up with a user-friendly naming scheme for spack dotfiles. ################################################################################# +# prevent infinite recursion when spack shells out (e.g., on cray for modules) +if test -n "$_sp_initializing" + exit 0 +end +set -x _sp_initializing true + # # Test for STDERR-NOCARET feature: if this is off, fish will redirect stderr to @@ -721,3 +727,6 @@ sp_multi_pathadd MODULEPATH $_sp_tcl_roots # [3]: When the test in the if statement fails, the `status` flag is set to 1. # `true` here manuallt resets the value of `status` to 0. Since `set` # passes `status` along, we thus avoid the function returning 1 by mistake. + +# done: unset sentinel variable as we're no longer initializing +set -e _sp_initializing |