Rewrite if statement

This commit is contained in:
Aaron
2023-02-23 17:10:28 +00:00
parent 6b692a85ef
commit e67c173403

View File

@@ -994,25 +994,24 @@ case "${SHELL}" in
;;
esac
in_shell_profile=$(grep -s "eval \"\$(${HOMEBREW_PREFIX}/bin/brew shellenv)\"" "${shell_profile}")
# FIXME: figure out why this give a "command not found" error
# show different instructions on adding Homebrew to path based on if the user has already done so
if [[ -n $in_shell_profile ]] && ! type brew &>/dev/null
if grep -qs "eval \"\$(${HOMEBREW_PREFIX}/bin/brew shellenv)\"" "${shell_profile}"
then
cat <<EOS
- Run this command in your terminal to add Homebrew to your ${tty_bold}PATH${tty_reset}:
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
EOS
elif ! "${in_shell_profile}"
then
cat <<EOS
- Run these two commands in your terminal to add Homebrew to your ${tty_bold}PATH${tty_reset}:
(echo; echo 'eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"') >> ${shell_profile}
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
if ! type brew &>/dev/null
then
cat <<EOS
- Run this command in your terminal to add Homebrew to your ${tty_bold}PATH${tty_reset}:
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
EOS
else
:
fi
else
:
cat <<EOS
- Run these two commands in your terminal to add Homebrew to your ${tty_bold}PATH${tty_reset}:
(echo; echo 'eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"') >> ${shell_profile}
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
EOS
fi
if [[ -n "${non_default_repos}" ]]