setup-env.sh: send cd output to /dev/null when it affects Spack

- We've seen this a few times now where users have set up `cd` to echo
  the new directory, and it screws up `setup-env.sh`

- In the past we've said this is user error.

- Here, we just fix it by sending `cd` output to /dev/null where needed.
  - this works in bash, zsh, and dash
This commit is contained in:
Todd Gamblin 2019-05-30 01:41:55 -05:00
parent 9c16b4a7f6
commit 600f3c1104

View file

@ -224,14 +224,6 @@ if [ -z "$_sp_source_file" ]; then
fi
fi
#
# Find root directory and add bin to path.
#
_sp_share_dir=$(cd "$(dirname $_sp_source_file)" && pwd)
_sp_prefix=$(cd "$(dirname $(dirname $_sp_share_dir))" && pwd)
_spack_pathadd PATH "${_sp_prefix%/}/bin"
export SPACK_ROOT=${_sp_prefix}
#
# Determine which shell is being used
#
@ -251,6 +243,17 @@ function _spack_determine_shell() {
}
export SPACK_SHELL=$(_spack_determine_shell)
#
# Find root directory and add bin to path.
#
# We send cd output to /dev/null to avoid because a lot of users set up
# their shell so that cd prints things out to the tty.
#
_sp_share_dir="$(cd "$(dirname $_sp_source_file)" > /dev/null && pwd)"
_sp_prefix="$(cd "$(dirname $(dirname $_sp_share_dir))" > /dev/null && pwd)"
_spack_pathadd PATH "${_sp_prefix%/}/bin"
export SPACK_ROOT="${_sp_prefix}"
#
# Check whether a function of the given name is defined
#