Skip to content

Commit

Permalink
bugfix: setup-env.sh detects bash even when bash is run as sh (spack#…
Browse files Browse the repository at this point in the history
…11994)

- `setup-env.sh` was not properly detecting a bash shell when bash was run
  as /bin/sh.

- Detection routine now always reports bash when bash is run as sh, and
  no longer parses the path to the executable indicated in `$BASH`.
  • Loading branch information
tgamblin authored Jul 12, 2019
1 parent 91e3554 commit e8e030a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions share/spack/setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,10 @@ _spack_pathadd() {
# Determine which shell is being used
#
_spack_determine_shell() {
# 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##*/}
echo bash
elif [ -n "${ZSH_NAME:-}" ]; then
echo $ZSH_NAME
echo zsh
else
PS_FORMAT= ps -p $$ | tail -n 1 | awk '{print $4}' | sed 's/^-//' | xargs basename
fi
Expand Down

0 comments on commit e8e030a

Please sign in to comment.