diff options
Diffstat (limited to 'share')
-rwxr-xr-x | share/spack/setup-env.sh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh index a8e918c1c9..f82a55d8f1 100755 --- a/share/spack/setup-env.sh +++ b/share/spack/setup-env.sh @@ -236,7 +236,18 @@ export SPACK_ROOT=${_sp_prefix} # Determine which shell is being used # function _spack_determine_shell() { - PS_FORMAT= ps -p $$ | tail -n 1 | awk '{print $4}' | sed 's/^-//' | xargs basename + # This logic is derived from the cea-hpc/modules profile.sh example at + # https://github.com/cea-hpc/modules/blob/master/init/profile.sh.in + # + # The objective is to correctly detect the shell type even when setup-env + # is sourced within a script itself rather than a login terminal. + if [ -n "${BASH:-}" ]; then + echo ${BASH##*/} + elif [ -n "${ZSH_NAME:-}" ]; then + echo $ZSH_NAME + else + PS_FORMAT= ps -p $$ | tail -n 1 | awk '{print $4}' | sed 's/^-//' | xargs basename + fi } export SPACK_SHELL=$(_spack_determine_shell) |