bin/brew: repair style
This commit is contained in:
parent
8853fb6c13
commit
40ec6250bc
41
bin/brew
41
bin/brew
@ -2,7 +2,7 @@
|
|||||||
set +o posix
|
set +o posix
|
||||||
|
|
||||||
# Fail fast with concise message when cwd does not exist
|
# Fail fast with concise message when cwd does not exist
|
||||||
if ! [[ -d "$PWD" ]]; then
|
if ! [[ -d "${PWD}" ]]; then
|
||||||
echo "Error: The current working directory doesn't exist, cannot proceed." >&2
|
echo "Error: The current working directory doesn't exist, cannot proceed." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -14,17 +14,17 @@ quiet_cd() {
|
|||||||
symlink_target_directory() {
|
symlink_target_directory() {
|
||||||
local target target_dirname
|
local target target_dirname
|
||||||
target="$(readlink "$1")"
|
target="$(readlink "$1")"
|
||||||
target_dirname="$(dirname "$target")"
|
target_dirname="$(dirname "${target}")"
|
||||||
local directory="$2"
|
local directory="$2"
|
||||||
quiet_cd "$directory" && quiet_cd "$target_dirname" && pwd -P
|
quiet_cd "${directory}" && quiet_cd "${target_dirname}" && pwd -P
|
||||||
}
|
}
|
||||||
|
|
||||||
# Enable and use default Bash builtins rather than user-defined functions
|
# Enable and use default Bash builtins rather than user-defined functions
|
||||||
builtin enable compgen unset
|
builtin enable compgen unset
|
||||||
for cmd in $(builtin compgen -A builtin)
|
for cmd in $(builtin compgen -A builtin)
|
||||||
do
|
do
|
||||||
builtin unset -f "$cmd"
|
builtin unset -f "${cmd}"
|
||||||
builtin enable "$cmd"
|
builtin enable "${cmd}"
|
||||||
done
|
done
|
||||||
unset cmd
|
unset cmd
|
||||||
|
|
||||||
@ -33,26 +33,26 @@ HOMEBREW_BREW_FILE="${BREW_FILE_DIRECTORY%/}/${0##*/}"
|
|||||||
HOMEBREW_PREFIX="${HOMEBREW_BREW_FILE%/*/*}"
|
HOMEBREW_PREFIX="${HOMEBREW_BREW_FILE%/*/*}"
|
||||||
|
|
||||||
# Default to / prefix if unset or the bin/brew file.
|
# Default to / prefix if unset or the bin/brew file.
|
||||||
if [[ -z "$HOMEBREW_PREFIX" || "$HOMEBREW_PREFIX" = "$HOMEBREW_BREW_FILE" ]]
|
if [[ -z "${HOMEBREW_PREFIX}" || "${HOMEBREW_PREFIX}" = "${HOMEBREW_BREW_FILE}" ]]
|
||||||
then
|
then
|
||||||
HOMEBREW_PREFIX="/"
|
HOMEBREW_PREFIX="/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOMEBREW_REPOSITORY="$HOMEBREW_PREFIX"
|
HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}"
|
||||||
|
|
||||||
# Resolve the bin/brew symlink to find Homebrew's repository
|
# Resolve the bin/brew symlink to find Homebrew's repository
|
||||||
if [[ -L "$HOMEBREW_BREW_FILE" ]]
|
if [[ -L "${HOMEBREW_BREW_FILE}" ]]
|
||||||
then
|
then
|
||||||
BREW_FILE_DIRECTORY="$(symlink_target_directory "$HOMEBREW_BREW_FILE" "$BREW_FILE_DIRECTORY")"
|
BREW_FILE_DIRECTORY="$(symlink_target_directory "${HOMEBREW_BREW_FILE}" "${BREW_FILE_DIRECTORY}")"
|
||||||
HOMEBREW_REPOSITORY="${BREW_FILE_DIRECTORY%/*}"
|
HOMEBREW_REPOSITORY="${BREW_FILE_DIRECTORY%/*}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to find a /usr/local HOMEBREW_PREFIX where possible (for bottles)
|
# Try to find a /usr/local HOMEBREW_PREFIX where possible (for bottles)
|
||||||
if [[ -L "/usr/local/bin/brew" && ! -L "$HOMEBREW_PREFIX/Cellar" ]]
|
if [[ -L "/usr/local/bin/brew" && ! -L "${HOMEBREW_PREFIX}/Cellar" ]]
|
||||||
then
|
then
|
||||||
USR_LOCAL_BREW_FILE_DIRECTORY="$(symlink_target_directory "/usr/local/bin/brew" "/usr/local/bin")"
|
USR_LOCAL_BREW_FILE_DIRECTORY="$(symlink_target_directory "/usr/local/bin/brew" "/usr/local/bin")"
|
||||||
USR_LOCAL_HOMEBREW_REPOSITORY="${USR_LOCAL_BREW_FILE_DIRECTORY%/*}"
|
USR_LOCAL_HOMEBREW_REPOSITORY="${USR_LOCAL_BREW_FILE_DIRECTORY%/*}"
|
||||||
if [[ "$HOMEBREW_REPOSITORY" = "$USR_LOCAL_HOMEBREW_REPOSITORY" ]]
|
if [[ "${HOMEBREW_REPOSITORY}" = "${USR_LOCAL_HOMEBREW_REPOSITORY}" ]]
|
||||||
then
|
then
|
||||||
HOMEBREW_PREFIX="/usr/local"
|
HOMEBREW_PREFIX="/usr/local"
|
||||||
fi
|
fi
|
||||||
@ -60,7 +60,7 @@ fi
|
|||||||
|
|
||||||
# If the location of HOMEBREW_LIBRARY changes
|
# If the location of HOMEBREW_LIBRARY changes
|
||||||
# keg_relocate.rb, formula_cellar_checks.rb, and test/global_spec.rb need to change.
|
# keg_relocate.rb, formula_cellar_checks.rb, and test/global_spec.rb need to change.
|
||||||
HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
|
HOMEBREW_LIBRARY="${HOMEBREW_REPOSITORY}/Library"
|
||||||
|
|
||||||
# Copy and export all HOMEBREW_* variables previously mentioned in
|
# Copy and export all HOMEBREW_* variables previously mentioned in
|
||||||
# manpage or used elsewhere by Homebrew.
|
# manpage or used elsewhere by Homebrew.
|
||||||
@ -72,7 +72,7 @@ do
|
|||||||
VAR_NEW="HOMEBREW_${VAR}"
|
VAR_NEW="HOMEBREW_${VAR}"
|
||||||
# Skip if existing HOMEBREW_* variable is set.
|
# Skip if existing HOMEBREW_* variable is set.
|
||||||
[[ -n "${!VAR_NEW}" ]] && continue
|
[[ -n "${!VAR_NEW}" ]] && continue
|
||||||
export "$VAR_NEW"="${!VAR}"
|
export "${VAR_NEW}"="${!VAR}"
|
||||||
done
|
done
|
||||||
|
|
||||||
export HOMEBREW_BREW_FILE
|
export HOMEBREW_BREW_FILE
|
||||||
@ -80,20 +80,23 @@ export HOMEBREW_PREFIX
|
|||||||
export HOMEBREW_REPOSITORY
|
export HOMEBREW_REPOSITORY
|
||||||
export HOMEBREW_LIBRARY
|
export HOMEBREW_LIBRARY
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
# Use VISUAL if HOMEBREW_EDITOR and EDITOR are unset.
|
# Use VISUAL if HOMEBREW_EDITOR and EDITOR are unset.
|
||||||
if [[ -z "$HOMEBREW_EDITOR" && -n "$VISUAL" ]]
|
if [[ -z "${HOMEBREW_EDITOR}" && -n "${VISUAL}" ]]
|
||||||
then
|
then
|
||||||
export HOMEBREW_EDITOR="$VISUAL"
|
export HOMEBREW_EDITOR="${VISUAL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
# Set CI variable for Azure Pipelines and Jenkins
|
# Set CI variable for Azure Pipelines and Jenkins
|
||||||
# (Set by default on GitHub Actions, Circle and Travis CI)
|
# (Set by default on GitHub Actions, Circle and Travis CI)
|
||||||
if [[ -z "$CI" ]] && [[ -n "$TF_BUILD" || -n "$JENKINS_HOME" ]]
|
if [[ -z "${CI}" ]] && [[ -n "${TF_BUILD}" || -n "${JENKINS_HOME}" ]]
|
||||||
then
|
then
|
||||||
export CI="1"
|
export CI="1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_NO_ENV_FILTERING" ]]
|
# shellcheck disable=SC2154
|
||||||
|
if [[ -z "${HOMEBREW_NO_ENV_FILTERING}" ]]
|
||||||
then
|
then
|
||||||
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
|
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
|
||||||
|
|
||||||
@ -111,11 +114,11 @@ then
|
|||||||
FILTERED_ENV+=( "${VAR}=${!VAR}" )
|
FILTERED_ENV+=( "${VAR}=${!VAR}" )
|
||||||
done
|
done
|
||||||
|
|
||||||
exec /usr/bin/env -i "${FILTERED_ENV[@]}" /bin/bash "$HOMEBREW_LIBRARY/Homebrew/brew.sh" "$@"
|
exec /usr/bin/env -i "${FILTERED_ENV[@]}" /bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" "$@"
|
||||||
else
|
else
|
||||||
echo "Warning: HOMEBREW_NO_ENV_FILTERING is undocumented, deprecated and will be removed in a future Homebrew release (because it breaks many things)!" >&2
|
echo "Warning: HOMEBREW_NO_ENV_FILTERING is undocumented, deprecated and will be removed in a future Homebrew release (because it breaks many things)!" >&2
|
||||||
|
|
||||||
# Don't need shellcheck to follow this `source`.
|
# Don't need shellcheck to follow this `source`.
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
|
source "${HOMEBREW_LIBRARY}/Homebrew/brew.sh"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user