diff options
-rwxr-xr-x | share/spack/setup-env.sh | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh index 9d984ae199..5761d16362 100755 --- a/share/spack/setup-env.sh +++ b/share/spack/setup-env.sh @@ -45,7 +45,8 @@ if [ -n "${_sp_initializing:-}" ]; then fi export _sp_initializing=true -spack() { + +_spack_shell_wrapper() { # Store LD_LIBRARY_PATH variables from spack shell function # This is necessary because MacOS System Integrity Protection clears # variables that affect dyld on process start. @@ -243,11 +244,6 @@ _spack_determine_shell() { _sp_shell=$(_spack_determine_shell) -# Export spack function so it is available in subshells (only works with bash) -if [ "$_sp_shell" = bash ]; then - export -f spack -fi - alias spacktivate="spack env activate" # @@ -315,6 +311,21 @@ if ! _spack_fn_exists use && ! _spack_fn_exists module; then need_module="yes" fi; +# Define the spack shell function with some informative no-ops, so when users +# run `which spack`, they see the path to spack and where the function is from. +eval "spack() { + : this is a shell function from: $_sp_share_dir/setup-env.sh + : the real spack script is here: $_sp_prefix/bin/spack + _spack_shell_wrapper \"\$@\" + return \$? +}" + +# Export spack function so it is available in subshells (only works with bash) +if [ "$_sp_shell" = bash ]; then + export -f spack + export -f _spack_shell_wrapper +fi + # # make available environment-modules # |