Harden shell detection when procfs is available (#13950)

This commit is contained in:
Massimiliano Culpo 2019-12-16 23:51:58 +01:00 committed by Todd Gamblin
parent e366d5b559
commit 9ceec7e219

View File

@ -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