From 513bc32d879ca8f106f60fc09db7a24d85c5c31d Mon Sep 17 00:00:00 2001 From: bcambl Date: Thu, 22 Dec 2016 19:57:13 -0600 Subject: [PATCH] is_repo: ensure directory exists --- automated install/basic-install.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index b5ba93ba..48e98f14 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -135,8 +135,14 @@ fi is_repo() { # Use git to check if directory is currently under VCS, return the value local directory="${1}" - curdir=$PWD; cd $directory; git status --short &> /dev/null; rc=$?; cd $curdir - return $rc + if [ -d $directory ]; then + # git -C is not used here to support git versions older than 1.8.4 + curdir=$PWD; cd $directory; git status --short &> /dev/null; rc=$?; cd $curdir + return $rc + else + # non-zero return code if directory does not exist OR is not a valid git repository + return 1 + fi } make_repo() {