summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
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() {