From 96c71e3254d688e8b20041e04b272fdf6446d7dd Mon Sep 17 00:00:00 2001 From: Dan OBoyle Date: Fri, 3 Jul 2015 17:46:18 -0400 Subject: [PATCH] Better logic for change_to_vcs_root --- bin/_blackbox_common.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 372a3b1..3c99583 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -295,17 +295,13 @@ function enumerate_subdirs() { # chdir to the base of the repo. function change_to_vcs_root() { # if vcs_root not explicitly defined, use $REPOBASE - if [[ -z "$1" ]]; then - cd "$REPOBASE" - elif is_blackbox_repo "$1"; then - cd "$1" - - else - echo 'ERROR: $1 is not a blackbox Repo' + local rbase=${1:-$REPOBASE} # use $1 but if unset use $REPOBASE + + if ! is_blackbox_repo "$rbase"; then + echo "ERROR: $rbase is not a blackbox Repo" exit 1 fi - } # $1 is a string pointing to a directory. Outputs a