Linuxbrew rc script - scanning paths

This commit is contained in:
Martin Blazik
2022-10-16 19:03:35 +02:00
parent 54d6072a42
commit ee6ebdc945

View File

@@ -1,16 +1,20 @@
# Homebrew initialization # Homebrew initialization
# Can set BREW_HOME in advance # Can set BREW_HOME in advance
BREW_LOCATIONS=( \ xlog "Homebrew initialization"
"$HOME/.local/share/linuxbrew" \
"$HOME/.linuxbrew" \ BREW_LOCATIONS=(
"/home/linuxbrew/.linuxbrew" \ "$HOME/.local/share/linuxbrew"
"$HOME/.linuxbrew"
"/home/linuxbrew/.linuxbrew"
) )
if [[ ! -d "$BREW_HOME" ]]; then if [[ -z "$BREW_HOME" ]]; then
for brew_path in "${BREW_LOCATIONS[@]}"; do for brew_path in "${BREW_LOCATIONS[@]}"; do
xlog "CHECK $brew_path"
if [[ -d "$brew_path" ]]; then if [[ -d "$brew_path" ]]; then
BREW_HOME="$brew_path" BREW_HOME="$brew_path"
xlog "FOUND $BREW_HOME"
break break
fi fi
done done
@@ -19,6 +23,7 @@ fi
BREW="$BREW_HOME/bin/brew" BREW="$BREW_HOME/bin/brew"
if [[ -e "$BREW" ]]; then if [[ -e "$BREW" ]]; then
xlog "Loading brew shell environment from $BREW_HOME"
path_backup="$PATH" path_backup="$PATH"
eval "$($BREW shellenv)" eval "$($BREW shellenv)"
PATH="$path_backup" PATH="$path_backup"
@@ -27,3 +32,5 @@ if [[ -e "$BREW" ]]; then
append_path "$HOMEBREW_PREFIX/sbin" append_path "$HOMEBREW_PREFIX/sbin"
fi fi
unset BREW
unset BREW_LOCATIONS