From 34197addaeb85f5a51dde716265309643b769961 Mon Sep 17 00:00:00 2001 From: Seppia Date: Wed, 30 May 2018 01:47:52 +0200 Subject: Variable and input checks Now checks if hardcoded variables have been set and eventually if their values are acceptable. --- repo.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/repo.sh b/repo.sh index 0003ddb..1b11af2 100755 --- a/repo.sh +++ b/repo.sh @@ -109,7 +109,11 @@ print_help() { echo } -if [ "$1" == '' ]; then +if [ "${SRC_PATH}" == '' ];then + echo 'ERROR: SRC_PATH variable not set.' +elif [ ! -d "${SRC_PATH}" ]; then + echo 'ERROR: SRC_PATH variable set to invalid path.' +elif [ "$1" == '' ]; then echo 'warning: no command called.' elif [ "$1" == 'add' ]; then if [ "$3" != '' ]; then @@ -144,6 +148,12 @@ elif [ "$1" == 'list' ]; then elif [ "$1" == 'update' ]; then if [ "$3" != '' ]; then echo 'error: too many arguments.' + elif [ "${REPO_PATH}" == '' ];then + echo 'ERROR: REPO_PATH variable not set.' + elif [ ! -d "${REPO_PATH}" ]; then + echo 'ERROR: REPO_PATH variable set to invalid path.' + elif [ "${REPO_NAME}" == '' ];then + echo 'ERROR: REPO_NAME variable not set.' elif [ "$2" != '' ]; then update_repo $2 else -- cgit v1.2.3