Skip to content

Commit

Permalink
Merge pull request #15818 from MikeMcQuaid/brew_env_home
Browse files Browse the repository at this point in the history
bin/brew: handle missing `$HOME`.
  • Loading branch information
MikeMcQuaid authored Aug 4, 2023
2 parents 11af9e8 + 59ea118 commit ef4731d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion bin/brew
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,30 @@ fi
if [[ -n "${XDG_CONFIG_HOME-}" ]]
then
HOMEBREW_USER_CONFIG_HOME="${XDG_CONFIG_HOME}/homebrew"
else
elif [[ -n "${HOME-}" ]]
then
HOMEBREW_USER_CONFIG_HOME="${HOME}/.homebrew"
elif [[ -n "${USER-}" ]]
then
if [[ "${OSTYPE}" == "darwin"* ]]
then
HOMEBREW_USER_CONFIG_HOME="/Users/${USER}/.homebrew"
else
HOMEBREW_USER_CONFIG_HOME="/home/${USER}/.homebrew"
fi
elif [[ -n "${LOGNAME-}" ]]
then
if [[ "${OSTYPE}" == "darwin"* ]]
then
HOMEBREW_USER_CONFIG_HOME="/Users/${LOGNAME}/.homebrew"
else
HOMEBREW_USER_CONFIG_HOME="/home/${LOGNAME}/.homebrew"
fi
else
echo "Error: \$HOME or \$USER or \$LOGNAME must be set to run brew." >&2
exit 1
fi

if [[ -f "${HOMEBREW_USER_CONFIG_HOME}/brew.env" ]]
then
# only load HOMEBREW_*=* lines
Expand Down

0 comments on commit ef4731d

Please sign in to comment.