From b7d8072575d3ff12207b386c7e13e2630335c537 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Wed, 13 Aug 2025 14:37:11 +0800 Subject: [PATCH] Restore handling of `HOMEBREW_BREW_WRAPPER` This now requires `HOMEBREW_DISABLE_NO_FORCE_BREW_WRAPPER` to be unset. If it is set (but only in a `brew.env` file), then we use the new functionality of checking the path of the parent process. --- Library/Homebrew/brew.sh | 50 +++++++++++++++++++++++++++++++++++++--- bin/brew | 3 +++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 76f760af9e..1e8fb39982 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -190,10 +190,54 @@ esac # Include some helper functions. source "${HOMEBREW_LIBRARY}/Homebrew/utils/helpers.sh" -# If HOMEBREW_FORCE_BREW_WRAPPER is set, verify that the path to our parent -# process is the same as the value of HOMEBREW_FORCE_BREW_WRAPPER for all +# Require HOMEBREW_BREW_WRAPPER to be set if HOMEBREW_FORCE_BREW_WRAPPER is set +# (and HOMEBREW_NO_FORCE_BREW_WRAPPER and HOMEBREW_DISABLE_NO_FORCE_BREW_WRAPPER are not set) +# for all non-trivial commands (i.e. not defined above this line e.g. formulae or --cellar). +if [[ -z "${HOMEBREW_NO_FORCE_BREW_WRAPPER:-}" && -n "${HOMEBREW_FORCE_BREW_WRAPPER:-}" && + -z "${HOMEBREW_DISABLE_NO_FORCE_BREW_WRAPPER:-}" ]] +then + HOMEBREW_FORCE_BREW_WRAPPER_WITHOUT_BREW="${HOMEBREW_FORCE_BREW_WRAPPER%/brew}" + if [[ -z "${HOMEBREW_BREW_WRAPPER:-}" ]] + then + # HOMEBREW_ORIGINAL_BREW_FILE set by bin/brew + # shellcheck disable=SC2154 + odie <