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 <