From 9dfb0bf20e291998a0690be15e3689e507ca226f Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Thu, 12 Feb 2026 14:57:27 -0800 Subject: [PATCH 1/4] setup script edits --- setup-env.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/setup-env.sh b/setup-env.sh index 20afd858a..3689f1674 100644 --- a/setup-env.sh +++ b/setup-env.sh @@ -1 +1,9 @@ -export PATH=${PWD}/bin:$PATH \ No newline at end of file +_this_file="${BASH_SOURCE[0]-${(%):-%N}-$0}" +_this_dir="$(CDPATH= cd -- "$(dirname -- "$_this_file")" 2>/dev/null && pwd -P)" + +if [ -n "$PATH" ] && [ ":$PATH:" != "${PATH#:$_this_dir/bin:}" ]; then + : # already present +else + PATH="$_this_dir/bin${PATH+:$PATH}" + export PATH +fi \ No newline at end of file From a3755142a1f1640643eeb4287beed1bde06b8f91 Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Thu, 12 Feb 2026 15:11:03 -0800 Subject: [PATCH 2/4] substring check is no longer fooled by a venv stored in the benchpark root --- setup-env.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/setup-env.sh b/setup-env.sh index 3689f1674..ef83b343f 100644 --- a/setup-env.sh +++ b/setup-env.sh @@ -1,9 +1,12 @@ _this_file="${BASH_SOURCE[0]-${(%):-%N}-$0}" _this_dir="$(CDPATH= cd -- "$(dirname -- "$_this_file")" 2>/dev/null && pwd -P)" -if [ -n "$PATH" ] && [ ":$PATH:" != "${PATH#:$_this_dir/bin:}" ]; then - : # already present -else - PATH="$_this_dir/bin${PATH+:$PATH}" - export PATH -fi \ No newline at end of file +case ":$PATH:" in + *":$_this_dir/bin:"*) + : # already present — do nothing + ;; + *) + PATH="$_this_dir/bin${PATH+:$PATH}" + export PATH + ;; +esac \ No newline at end of file From b81f48ac362ad53bd893741f7769dd1a4517d0e8 Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Thu, 12 Feb 2026 15:43:49 -0800 Subject: [PATCH 3/4] add some explanatory comments --- setup-env.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup-env.sh b/setup-env.sh index ef83b343f..87e750adb 100644 --- a/setup-env.sh +++ b/setup-env.sh @@ -1,4 +1,6 @@ +# BASH_SOURCE[0] if it exists, or ${(%):-%N} in zsh, or $0 as a final fallback _this_file="${BASH_SOURCE[0]-${(%):-%N}-$0}" +# Get abspath _this_dir="$(CDPATH= cd -- "$(dirname -- "$_this_file")" 2>/dev/null && pwd -P)" case ":$PATH:" in From 828917a5b25fb8a06e8fbdfd2f9b1dcfb0a7427e Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Thu, 12 Feb 2026 15:59:32 -0800 Subject: [PATCH 4/4] support only bash and zsh; expand comment --- setup-env.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/setup-env.sh b/setup-env.sh index 87e750adb..314f6e138 100644 --- a/setup-env.sh +++ b/setup-env.sh @@ -1,11 +1,22 @@ -# BASH_SOURCE[0] if it exists, or ${(%):-%N} in zsh, or $0 as a final fallback -_this_file="${BASH_SOURCE[0]-${(%):-%N}-$0}" +if [ -n "${BASH_VERSION-}" ]; then + _this_file=${BASH_SOURCE[0]} +elif [ -n "${ZSH_VERSION-}" ]; then + eval '_this_file=${(%):-%N}' +else + echo "This script must be sourced from bash or zsh." >&2 + return 1 2>/dev/null || exit 1 +fi # Get abspath _this_dir="$(CDPATH= cd -- "$(dirname -- "$_this_file")" 2>/dev/null && pwd -P)" case ":$PATH:" in *":$_this_dir/bin:"*) - : # already present — do nothing + # already present: do nothing + # This is an exact match, and e.g. won't match if PATH contains this + # dir with a trailing slash after "bin". That's good enough to avoid + # adding duplicate entries when re-sourcing this, but will add a + # duplicate if the user manually added .../bin/ to their PATH + : ;; *) PATH="$_this_dir/bin${PATH+:$PATH}"