mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
bin/brew: improve /usr/local/bin/brew handling.
If `/usr/local` is the prefix but not the repository (so bottles can be used) then running `/usr/local/bin/brew` works great but `$HOMEBREW_REPOSITORY/bin/brew` assumes the prefix is `$HOMEBREW_REPOSITORY`. This is a pain when doing work on the Homebrew repository and having e.g. `bin` in your `$PATH`. Improve this behaviour so `bin/brew` knows how to handle this situation.
This commit is contained in:
parent
2f9bf5f047
commit
d0ff64666a
11
bin/brew
11
bin/brew
@ -31,6 +31,17 @@ then
|
|||||||
HOMEBREW_REPOSITORY="${BREW_FILE_DIRECTORY%/*}"
|
HOMEBREW_REPOSITORY="${BREW_FILE_DIRECTORY%/*}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Try to find a /usr/local HOMEBREW_PREFIX where possible (for bottles)
|
||||||
|
if [[ -L "/usr/local/bin/brew" ]]
|
||||||
|
then
|
||||||
|
USR_LOCAL_BREW_FILE_DIRECTORY="$(symlink_target_directory "/usr/local/bin/brew" "/usr/local/bin")"
|
||||||
|
USR_LOCAL_HOMEBREW_REPOSITORY="${USR_LOCAL_BREW_FILE_DIRECTORY%/*}"
|
||||||
|
if [[ "$HOMEBREW_REPOSITORY" = "$USR_LOCAL_HOMEBREW_REPOSITORY" ]]
|
||||||
|
then
|
||||||
|
HOMEBREW_PREFIX="/usr/local"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
|
HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
|
||||||
|
|
||||||
source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
|
source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user