From 121624e0c219ee3b2db22cd6394a7ddec3d039ad Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Mon, 2 Sep 2024 17:02:08 +0800 Subject: [PATCH] Revert "cmd/shellenv: improve for newer macOS using `/usr/libexec/path_helper`" --- Library/Homebrew/brew.sh | 11 ++++------- Library/Homebrew/cmd/shellenv.sh | 31 ++----------------------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 2ab0d5ccca982..136da511f963f 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -54,13 +54,6 @@ then HOMEBREW_DEFAULT_CACHE="${HOME}/Library/Caches/Homebrew" HOMEBREW_DEFAULT_LOGS="${HOME}/Library/Logs/Homebrew" HOMEBREW_DEFAULT_TEMP="/private/tmp" - - HOMEBREW_MACOS_VERSION="$(/usr/bin/sw_vers -productVersion)" - - IFS=. read -r -a MACOS_VERSION_ARRAY <<<"${HOMEBREW_MACOS_VERSION}" - printf -v HOMEBREW_MACOS_VERSION_NUMERIC "%02d%02d%02d" "${MACOS_VERSION_ARRAY[@]}" - - unset MACOS_VERSION_ARRAY else CACHE_HOME="${HOMEBREW_XDG_CACHE_HOME:-${HOME}/.cache}" HOMEBREW_DEFAULT_CACHE="${CACHE_HOME}/Homebrew" @@ -530,6 +523,7 @@ then HOMEBREW_PRODUCT="Homebrew" HOMEBREW_SYSTEM="Macintosh" [[ "${HOMEBREW_PROCESSOR}" == "x86_64" ]] && HOMEBREW_PROCESSOR="Intel" + HOMEBREW_MACOS_VERSION="$(/usr/bin/sw_vers -productVersion)" # Don't change this from Mac OS X to match what macOS itself does in Safari on 10.12 HOMEBREW_OS_USER_AGENT_VERSION="Mac OS X ${HOMEBREW_MACOS_VERSION}" @@ -540,6 +534,9 @@ then HOMEBREW_PHYSICAL_PROCESSOR="arm64" fi + IFS=. read -r -a MACOS_VERSION_ARRAY <<<"${HOMEBREW_MACOS_VERSION}" + printf -v HOMEBREW_MACOS_VERSION_NUMERIC "%02d%02d%02d" "${MACOS_VERSION_ARRAY[@]}" + IFS=. read -r -a MACOS_VERSION_ARRAY <<<"${HOMEBREW_MACOS_OLDEST_ALLOWED}" printf -v HOMEBREW_MACOS_OLDEST_ALLOWED_NUMERIC "%02d%02d%02d" "${MACOS_VERSION_ARRAY[@]}" diff --git a/Library/Homebrew/cmd/shellenv.sh b/Library/Homebrew/cmd/shellenv.sh index a4af9b9a7219d..3070a10b02ecf 100644 --- a/Library/Homebrew/cmd/shellenv.sh +++ b/Library/Homebrew/cmd/shellenv.sh @@ -18,23 +18,6 @@ homebrew-shellenv() { HOMEBREW_SHELL_NAME="$(/bin/ps -p "${PPID}" -c -o comm=)" fi - if [[ -n "${HOMEBREW_MACOS}" ]] && - [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -ge "140000" ]] && - [[ -x /usr/libexec/path_helper ]] - then - HOMEBREW_PATHS_FILE="${HOMEBREW_PREFIX}/etc/paths" - - if [[ ! -f "${HOMEBREW_PATHS_FILE}" ]] - then - printf '%s/bin\n%s/sbin\n' "${HOMEBREW_PREFIX}" "${HOMEBREW_PREFIX}" >"${HOMEBREW_PATHS_FILE}" 2>/dev/null - fi - - if [[ -r "${HOMEBREW_PATHS_FILE}" ]] - then - PATH_HELPER_ROOT="${HOMEBREW_PREFIX}" - fi - fi - case "${HOMEBREW_SHELL_NAME}" in fish | -fish) echo "set -gx HOMEBREW_PREFIX \"${HOMEBREW_PREFIX}\";" @@ -48,12 +31,7 @@ homebrew-shellenv() { echo "setenv HOMEBREW_PREFIX ${HOMEBREW_PREFIX};" echo "setenv HOMEBREW_CELLAR ${HOMEBREW_CELLAR};" echo "setenv HOMEBREW_REPOSITORY ${HOMEBREW_REPOSITORY};" - if [[ -n "${PATH_HELPER_ROOT}" ]] - then - echo "eval \`/usr/bin/env PATH_HELPER_ROOT=\"${PATH_HELPER_ROOT}\" /usr/libexec/path_helper -c\`;" - else - echo "setenv PATH ${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:\$PATH;" - fi + echo "setenv PATH ${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:\$PATH;" echo "test \${?MANPATH} -eq 1 && setenv MANPATH :\${MANPATH};" echo "setenv INFOPATH ${HOMEBREW_PREFIX}/share/info\`test \${?INFOPATH} -eq 1 && echo :\${INFOPATH}\`;" ;; @@ -69,12 +47,7 @@ homebrew-shellenv() { echo "export HOMEBREW_PREFIX=\"${HOMEBREW_PREFIX}\";" echo "export HOMEBREW_CELLAR=\"${HOMEBREW_CELLAR}\";" echo "export HOMEBREW_REPOSITORY=\"${HOMEBREW_REPOSITORY}\";" - if [[ -n "${PATH_HELPER_ROOT}" ]] - then - echo "eval \"\$(PATH_HELPER_ROOT=\"${PATH_HELPER_ROOT}\" /usr/libexec/path_helper -s)\"" - else - echo "export PATH=\"${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin\${PATH+:\$PATH}\";" - fi + echo "export PATH=\"${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin\${PATH+:\$PATH}\";" echo "[ -z \"\${MANPATH-}\" ] || export MANPATH=\":\${MANPATH#:}\";" echo "export INFOPATH=\"${HOMEBREW_PREFIX}/share/info:\${INFOPATH:-}\";" ;;