From 10d8ed4d98314f298c5fd28d726834129510fbd5 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Thu, 28 Apr 2016 15:43:05 -0700 Subject: check that a target directory exists before committing to cd --- share/spack/setup-env.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'share') diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh index 764af68400..e3dd1cb4b9 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 ;; -- cgit v1.2.3-70-g09d2 From 584501a1cc34165671d0d4e9e2ae27d9cae8cdf9 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Fri, 29 Apr 2016 09:33:54 -0700 Subject: switched test to use -d for location check --- share/spack/setup-env.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'share') diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh index e3dd1cb4b9..11a4c0a70c 100755 --- a/share/spack/setup-env.sh +++ b/share/spack/setup-env.sh @@ -84,10 +84,10 @@ function spack { if [ "$_sp_arg" = "-h" ]; then command spack cd -h else - LOC="$(spack location $_sp_arg "$@")" - if [[ "x" -ne "x$LOC" ]] ; then + LOC="$(spack location $_sp_arg "$@")" + if [[ -d "$LOC" ]] ; then cd "$LOC" - fi + fi fi return ;; -- cgit v1.2.3-70-g09d2