瀏覽代碼

chore: stat to resolve script dir on macos and realpath otherwise

Ivan Dyachkov 3 年之前
父節點
當前提交
b3a7fd26dc
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      bin/emqx

+ 5 - 1
bin/emqx

@@ -7,7 +7,11 @@ set -euo pipefail
 DEBUG="${DEBUG:-0}"
 DEBUG="${DEBUG:-0}"
 [ "$DEBUG" -eq 1 ] && set -x
 [ "$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
 # shellcheck disable=SC1090,SC1091
 . "$RUNNER_ROOT_DIR"/releases/emqx_vars
 . "$RUNNER_ROOT_DIR"/releases/emqx_vars