diff --git a/Library/Homebrew/cmd/shellenv.sh b/Library/Homebrew/cmd/shellenv.sh index 2434efee15..4ed9ecb6e8 100644 --- a/Library/Homebrew/cmd/shellenv.sh +++ b/Library/Homebrew/cmd/shellenv.sh @@ -10,7 +10,8 @@ # HOMEBREW_REPOSITORY is set by bin/brew # shellcheck disable=SC2154 homebrew-shellenv() { - [[ "${HOMEBREW_SHELLENV_PREFIX}" == "${HOMEBREW_PREFIX}" ]] && return + [[ "${HOMEBREW_SHELLENV_PREFIX}" == "${HOMEBREW_PREFIX}" && + "$(PATH="${HOMEBREW_PATH}" command -v brew)" == "${HOMEBREW_PREFIX}/bin/brew" ]] && return case "$(/bin/ps -p "${PPID}" -c -o comm=)" in fish | -fish)