diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 764af684001706f9240319c6a1b054494aae2762..e3dd1cb4b9a2e90aba2e0c4afd587450b4255ef2 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -1,4 +1,4 @@
-##############################################################################
+#####################################################################
 # Copyright (c) 2013, Lawrence Livermore National Security, LLC.
 # Produced at the Lawrence Livermore National Laboratory.
 #
@@ -84,7 +84,10 @@ function spack {
             if [ "$_sp_arg" = "-h" ]; then
                 command spack cd -h
             else
-                cd $(spack location $_sp_arg "$@")
+		LOC="$(spack location $_sp_arg "$@")"
+		if [[ "x" -ne "x$LOC" ]] ; then
+                    cd "$LOC"
+		fi
             fi
             return
             ;;