Merge pull request #9 from bonidier/script_realpath

fix BASE_PATH, resolving real path the script, to allow symlink this one
pull/12/head
Antoine Leveugle 2018-02-20 13:32:36 +01:00 committed by GitHub
commit a8df712a46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -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"