Skip to content

Commit 2a3fd3b

Browse files
committed
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.
1 parent 23d54a0 commit 2a3fd3b

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

lib/helpers.bash

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,17 @@ function _completion_exists ()
5050

5151
function _bash_it_homebrew_check()
5252
{
53-
if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]]
54-
then # variable isn't set
55-
if _binary_exists 'brew'
56-
then # Homebrew is installed
53+
if _binary_exists 'brew'
54+
then # Homebrew is installed
55+
if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]]
56+
then # variable isn't set
5757
BASH_IT_HOMEBREW_PREFIX="$(brew --prefix)"
58-
else # Homebrew is not installed.
59-
false # return failure if brew not installed.
58+
else
59+
true # Variable is set already, don't invoke `brew`.
6060
fi
61+
else # Homebrew is not installed.
62+
BASH_IT_HOMEBREW_PREFIX= # clear variable, if set to anything.
63+
false # return failure if brew not installed.
6164
fi
6265
}
6366

0 commit comments

Comments
 (0)