Skip to content

Commit 1fbd624

Browse files
authored
Merge pull request #1067 from Homebrew/shellenv_suffix
2 parents ff566e5 + 75916be commit 1fbd624

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

install.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ EOS
10721072
ohai "Next steps:"
10731073
case "${SHELL}" in
10741074
*/bash*)
1075+
shellenv_suffix=" bash"
10751076
if [[ -n "${HOMEBREW_ON_LINUX-}" ]]
10761077
then
10771078
shell_rcfile="${HOME}/.bashrc"
@@ -1080,6 +1081,7 @@ case "${SHELL}" in
10801081
fi
10811082
;;
10821083
*/zsh*)
1084+
shellenv_suffix=" zsh"
10831085
if [[ -n "${HOMEBREW_ON_LINUX-}" ]]
10841086
then
10851087
shell_rcfile="${ZDOTDIR:-"${HOME}"}/.zshrc"
@@ -1088,28 +1090,30 @@ case "${SHELL}" in
10881090
fi
10891091
;;
10901092
*/fish*)
1093+
shellenv_suffix=" fish"
10911094
shell_rcfile="${HOME}/.config/fish/config.fish"
10921095
;;
10931096
*)
1097+
shellenv_suffix=""
10941098
shell_rcfile="${ENV:-"${HOME}/.profile"}"
10951099
;;
10961100
esac
10971101

1098-
if grep -qs "eval \"\$(${HOMEBREW_PREFIX}/bin/brew shellenv)\"" "${shell_rcfile}"
1102+
if grep -qs "eval \"\$(${HOMEBREW_PREFIX}/bin/brew shellenv[^\"]*)\"" "${shell_rcfile}"
10991103
then
11001104
if ! [[ -x "$(command -v brew)" ]]
11011105
then
11021106
cat <<EOS
11031107
- Run this command in your terminal to add Homebrew to your ${tty_bold}PATH${tty_reset}:
1104-
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
1108+
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv${shellenv_suffix})"
11051109
EOS
11061110
fi
11071111
else
11081112
cat <<EOS
11091113
- Run these commands in your terminal to add Homebrew to your ${tty_bold}PATH${tty_reset}:
11101114
echo >> ${shell_rcfile}
1111-
echo 'eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"' >> ${shell_rcfile}
1112-
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
1115+
echo 'eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv${shellenv_suffix})"' >> ${shell_rcfile}
1116+
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv${shellenv_suffix})"
11131117
EOS
11141118
fi
11151119

0 commit comments

Comments
 (0)