lib/helpers: invert test in _bash_it_homebrew_check()

Check if `brew` is installed every time, and *unset* `$BASH_IT_HOMEBREW_PREFIX` if not found. This accounts for the edge-case of a user _uninstalling_ Homebrew without restarting the shell.
pull/1910/head
John D Pell 2021-08-14 18:23:06 -07:00
parent 65ef8e2e8b
commit 0f28824ad5
1 changed files with 9 additions and 6 deletions

View File

@ -50,14 +50,17 @@ function _completion_exists ()
function _bash_it_homebrew_check() function _bash_it_homebrew_check()
{ {
if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]]
then # variable isn't set
if _binary_exists 'brew' if _binary_exists 'brew'
then # Homebrew is installed then # Homebrew is installed
if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]]
then # variable isn't set
BASH_IT_HOMEBREW_PREFIX="$(brew --prefix)" BASH_IT_HOMEBREW_PREFIX="$(brew --prefix)"
else # Homebrew is not installed. else
false # return failure if brew not installed. true # Variable is set already, don't invoke `brew`.
fi fi
else # Homebrew is not installed.
BASH_IT_HOMEBREW_PREFIX= # clear variable, if set to anything.
false # return failure if brew not installed.
fi fi
} }