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
|
exit 1
|
||||||
fi
|
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() {
|
quiet_cd() {
|
||||||
cd "$@" &>/dev/null || return
|
cd "$@" &>/dev/null || return
|
||||||
}
|
}
|
||||||
@ -107,28 +114,8 @@ export_homebrew_env_file "${HOMEBREW_PREFIX}/etc/homebrew/brew.env"
|
|||||||
if [[ -n "${XDG_CONFIG_HOME-}" ]]
|
if [[ -n "${XDG_CONFIG_HOME-}" ]]
|
||||||
then
|
then
|
||||||
HOMEBREW_USER_CONFIG_HOME="${XDG_CONFIG_HOME}/homebrew"
|
HOMEBREW_USER_CONFIG_HOME="${XDG_CONFIG_HOME}/homebrew"
|
||||||
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
|
else
|
||||||
echo "Error: \$HOME or \$USER or \$LOGNAME must be set to run brew." >&2
|
HOMEBREW_USER_CONFIG_HOME="${HOME}/.homebrew"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export_homebrew_env_file "${HOMEBREW_USER_CONFIG_HOME}/brew.env"
|
export_homebrew_env_file "${HOMEBREW_USER_CONFIG_HOME}/brew.env"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user