Merge pull request #17421 from Homebrew/original-path-fix

bin/brew: fix tracking of original paths with brew-in-brew calls
This commit is contained in:
Mike McQuaid 2024-06-04 08:48:17 +01:00 committed by GitHub
commit 62f2e3377d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -391,9 +391,6 @@ auto-update() {
unset HOMEBREW_AUTO_UPDATING
unset HOMEBREW_AUTO_UPDATE_TAP
# Restore user path as it'll be refiltered by HOMEBREW_BREW_FILE (bin/brew)
export PATH=${HOMEBREW_PATH}
# exec a new process to set any new environment variables.
exec "${HOMEBREW_BREW_FILE}" "$@"
fi

View File

@ -57,6 +57,12 @@ do
done
unset cmd
# Take the HOMEBREW_PATH if we are running brew within brew, otherwise we would lose the original path.
if [[ -n "${HOMEBREW_BREW_FILE:-}" && -n "${HOMEBREW_PATH:-}" ]]
then
PATH="${HOMEBREW_PATH}"
fi
BREW_FILE_DIRECTORY="$(quiet_cd "${0%/*}/" && pwd -P)"
HOMEBREW_BREW_FILE="${BREW_FILE_DIRECTORY%/}/${0##*/}"
HOMEBREW_PREFIX="${HOMEBREW_BREW_FILE%/*/*}"