Skip to content

Commit

Permalink
Fix HOMEBREW_*BREW_WRAPPER behaviour
Browse files Browse the repository at this point in the history
- handle reading from variables that may not be defined yet
- avoid unnecessary handling of defined variables
- fix incorrect `env_config.rbi` file entry
- add `HOMEBREW_NO_FORCE_BREW_WRAPPER` to disable
  `HOMEBREW_FORCE_BREW_WRAPPER` functionality if needed
  • Loading branch information
MikeMcQuaid committed Jan 8, 2025
1 parent cbf92f3 commit bb74d26
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ esac
source "${HOMEBREW_LIBRARY}/Homebrew/utils/helpers.sh"

# Require HOMEBREW_BREW_WRAPPER to be set if HOMEBREW_FORCE_BREW_WRAPPER is set
# for all non-trivial commands (i.e. not run above).
if [[ -n "${HOMEBREW_FORCE_BREW_WRAPPER}" ]]
# (and HOMEBREW_NO_FORCE_BREW_WRAPPER is 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:-}" ]]
then
if [[ -z "${HOMEBREW_BREW_WRAPPER:-}" ]]
then
Expand All @@ -195,7 +196,7 @@ but HOMEBREW_BREW_WRAPPER was unset. This indicates that you are running
directly but should instead run
${HOMEBREW_FORCE_BREW_WRAPPER}
EOS
elif [[ "${HOMEBREW_FORCE_BREW_WRAPPER:-}" != "${HOMEBREW_BREW_WRAPPER:-}" ]]
elif [[ "${HOMEBREW_FORCE_BREW_WRAPPER}" != "${HOMEBREW_BREW_WRAPPER}" ]]
then
odie <<EOS
HOMEBREW_FORCE_BREW_WRAPPER was set to
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ module EnvConfig
description: "If set, do not print any hints about changing Homebrew's behaviour with environment variables.",
boolean: true,
},
HOMEBREW_NO_FORCE_BREW_WRAPPER: {
description: "If set, disables `HOMEBREW_FORCE_BREW_WRAPPER` behaviour, even if set.",
boolean: true,
},
HOMEBREW_NO_GITHUB_API: {
description: "If set, do not use the GitHub API, e.g. for searches or fetching relevant issues " \
"after a failed install.",
Expand Down
7 changes: 5 additions & 2 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bb74d26

Please sign in to comment.