From 9ceec7e21984db4ddb51756a6178e6c305b27238 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Mon, 16 Dec 2019 23:51:58 +0100 Subject: Harden shell detection when procfs is available (#13950) --- share/spack/setup-env.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh index d5cad059a6..ab2655ddf6 100755 --- a/share/spack/setup-env.sh +++ b/share/spack/setup-env.sh @@ -215,11 +215,14 @@ _spack_pathadd() { } -# # Determine which shell is being used -# _spack_determine_shell() { - if [ -n "${BASH:-}" ]; then + if [ -f "/proc/$$/exe" ]; then + # If procfs is present this seems a more reliable + # way to detect the current shell + _sp_exe=$(readlink /proc/$$/exe) + basename ${_sp_exe} + elif [ -n "${BASH:-}" ]; then echo bash elif [ -n "${ZSH_NAME:-}" ]; then echo zsh -- cgit v1.2.3-60-g2f50