From e47fb83ca0044573490bd5cccef6bf6bebed0c3b Mon Sep 17 00:00:00 2001 From: Didier BONNEFOI Date: Tue, 20 Feb 2018 12:15:36 +0100 Subject: [PATCH] fix BASE_PATH, resolving real path the script, to allow symlink this one --- ovh-api-bash-client.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ovh-api-bash-client.sh b/ovh-api-bash-client.sh index 718b232..298e583 100755 --- a/ovh-api-bash-client.sh +++ b/ovh-api-bash-client.sh @@ -19,7 +19,19 @@ declare -A API_CREATE_APP_URLS API_CREATE_APP_URLS[CA]="https://ca.api.ovh.com/createApp/" API_CREATE_APP_URLS[EU]="https://api.ovh.com/createApp/" -BASE_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +## https://gist.github.com/TheMengzor/968e5ea87e99d9c41782 +# resolve $SOURCE until the file is no longer a symlink +SOURCE="${BASH_SOURCE[0]}" +while [ -h "${SOURCE}" ] +do + DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )" + SOURCE="$(readlink "${SOURCE}")" + # if $SOURCE was a relative symlink, + # we need to resolve it relative to the path where the symlink file was located + [[ ${SOURCE} != /* ]] && SOURCE="${DIR}/${SOURCE}" +done +BASE_PATH=$( cd -P "$( dirname "${SOURCE}" )" && pwd ) + PROFILES_PATH="${BASE_PATH}/profile" HELP_CMD="$0"