From b6d0ca28d5fd2b63c7da67b127e6c2a0e01b2670 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Mon, 27 Mar 2023 23:42:55 -0700 Subject: [PATCH] fix!: do not remove items from PATH in POSIX entrypoint (#1521) --- asdf.sh | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/asdf.sh b/asdf.sh index d7dd4c7e..cdbb1de8 100644 --- a/asdf.sh +++ b/asdf.sh @@ -47,7 +47,7 @@ if [ -z "$ASDF_DIR" ]; then fi if [ -z "$ASDF_DIR" ]; then - printf "%s\n" "asdf: Error: Source directory could not be calculated. Please set it manually before sourcing this file." >&2 + printf "%s\n" "asdf: Error: Source directory could not be calculated. Please set \$ASDF_DIR manually before sourcing this file." >&2 return 1 fi @@ -56,22 +56,20 @@ if [ ! -d "$ASDF_DIR" ]; then return 1 fi -_asdf_bin="${ASDF_DIR}/bin" +_asdf_bin="$ASDF_DIR/bin" _asdf_shims="${ASDF_DATA_DIR:-$HOME/.asdf}/shims" -# shellcheck disable=SC3060 -if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then - case ":$PATH:" in - *":${_asdf_bin}:"*) PATH="${PATH//$_asdf_bin:/}" ;; - esac - case ":$PATH:" in - *":${_asdf_shims}:"*) PATH="${PATH//$_asdf_shims:/}" ;; - esac -fi +case ":$PATH:" in + *":$_asdf_bin:"*) : ;; + *) PATH="$_asdf_bin:$PATH" ;; +esac +case ":$PATH:" in + *":$_asdf_shims:"*) : ;; + *) PATH="$_asdf_shims:$PATH" ;; +esac -PATH="${_asdf_bin}:${_asdf_shims}:$PATH" unset -v _asdf_bin _asdf_shims # shellcheck source=lib/asdf.sh -. "${ASDF_DIR}/lib/asdf.sh" +. "$ASDF_DIR/lib/asdf.sh"