From 5670d5c0bbcb148feabef84400a07cfca9aa3b30 Mon Sep 17 00:00:00 2001 From: Aurora-NICExq Date: Fri, 18 Sep 2026 18:20:25 +0800 Subject: [PATCH] fix(yt-wsp): Resolve script path without GNU realpath (#4072) macOS ships BSD realpath, which rejects -e and is missing on older releases. Use plain realpath when present, otherwise cd and pwd -P. Fixes #530 Co-authored-by: Aurora-NICExq --- examples/yt-wsp.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/yt-wsp.sh b/examples/yt-wsp.sh index 835508cca..0393e9974 100755 --- a/examples/yt-wsp.sh +++ b/examples/yt-wsp.sh @@ -39,7 +39,11 @@ set -Eeuo pipefail # get script file location -SCRIPT_PATH="$(realpath -e ${BASH_SOURCE[0]})"; +if [ -x "$(command -v realpath)" ]; then + SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")" +else + SCRIPT_PATH="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)/$(basename -- "${BASH_SOURCE[0]}")" +fi SCRIPT_DIR="${SCRIPT_PATH%/*}" ################################################################################