Skip to content

Commit

Permalink
Merge pull request #18224 from Homebrew/revert-18188-better-shellenv
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid authored Sep 2, 2024
2 parents cd5cf4e + 121624e commit 1f9bd2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 36 deletions.
11 changes: 4 additions & 7 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}"

Expand All @@ -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[@]}"

Expand Down
31 changes: 2 additions & 29 deletions Library/Homebrew/cmd/shellenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}\";"
Expand All @@ -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}\`;"
;;
Expand All @@ -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:-}\";"
;;
Expand Down

0 comments on commit 1f9bd2d

Please sign in to comment.