Merge pull request #9095 from emqx/chore-fix-script-path-resolution-on-macos

chore: stat to resolve script dir on macos and readlink -f otherwise
This commit is contained in:
Ivan Dyachkov 2022-10-05 15:38:10 +02:00 committed by GitHub
commit 5deba61dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -7,7 +7,11 @@ set -euo pipefail
DEBUG="${DEBUG:-0}"
[ "$DEBUG" -eq 1 ] && set -x
RUNNER_ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)"
if [ "$(uname -s)" == 'Darwin' ]; then
RUNNER_ROOT_DIR="$(cd "$(dirname "$(stat -f%R "$0" || echo "$0")")"/..; pwd -P)"
else
RUNNER_ROOT_DIR="$(cd "$(dirname "$(realpath "$0" || echo "$0")")"/..; pwd -P)"
fi
# shellcheck disable=SC1090,SC1091
. "$RUNNER_ROOT_DIR"/releases/emqx_vars