summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-05-30 01:41:55 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2019-06-29 19:01:44 -0700
commit600f3c11042a77c44aff4372aba59d56cdc76955 (patch)
tree67977282a1282ac552b37f9ab78b2cf3da689861 /share
parent9c16b4a7f6527db3f30e79b14a0d066084c8508f (diff)
downloadspack-600f3c11042a77c44aff4372aba59d56cdc76955.tar.gz
spack-600f3c11042a77c44aff4372aba59d56cdc76955.tar.bz2
spack-600f3c11042a77c44aff4372aba59d56cdc76955.tar.xz
spack-600f3c11042a77c44aff4372aba59d56cdc76955.zip
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
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/setup-env.sh21
1 files changed, 12 insertions, 9 deletions
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 8821751a05..a00681ef7f 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -207,7 +207,7 @@ function _spack_pathadd {
# Export spack function so it is available in subshells (only works with bash)
if [ -n "${BASH_VERSION:-}" ]; then
- export -f spack
+ export -f spack
fi
#
@@ -225,14 +225,6 @@ if [ -z "$_sp_source_file" ]; then
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
#
function _spack_determine_shell() {
@@ -252,6 +244,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
#
function _spack_fn_exists() {