mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
bin/brew: require HOME to be set.
Rather than having increasingly involved workarounds that require other variables to be set. Closes #15822
This commit is contained in:
parent
22afefce8e
commit
4184546067
29
bin/brew
29
bin/brew
@ -19,6 +19,13 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Fail fast with concise message when HOME is unset
|
||||
if [[ -z "${HOME:-}" ]]
|
||||
then
|
||||
echo "Error: \$HOME must be set to run brew." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
quiet_cd() {
|
||||
cd "$@" &>/dev/null || return
|
||||
}
|
||||
@ -107,28 +114,8 @@ export_homebrew_env_file "${HOMEBREW_PREFIX}/etc/homebrew/brew.env"
|
||||
if [[ -n "${XDG_CONFIG_HOME-}" ]]
|
||||
then
|
||||
HOMEBREW_USER_CONFIG_HOME="${XDG_CONFIG_HOME}/homebrew"
|
||||
elif [[ -n "${HOME-}" ]]
|
||||
then
|
||||
else
|
||||
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
|
||||
|
||||
export_homebrew_env_file "${HOMEBREW_USER_CONFIG_HOME}/brew.env"
|
||||
|
Loading…
x
Reference in New Issue
Block a user