mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Fix brew style
shellcheck warnings.
This commit is contained in:
parent
96504ec9dc
commit
4feb851279
@ -26,7 +26,7 @@ export HOMEBREW_COMMAND_DEPTH=$((HOMEBREW_COMMAND_DEPTH + 1))
|
|||||||
onoe() {
|
onoe() {
|
||||||
if [[ -t 2 ]] # check whether stderr is a tty.
|
if [[ -t 2 ]] # check whether stderr is a tty.
|
||||||
then
|
then
|
||||||
echo -ne "\033[4;31mError\033[0m: " >&2 # highlight Error with underline and red color
|
echo -ne "\\033[4;31mError\\033[0m: " >&2 # highlight Error with underline and red color
|
||||||
else
|
else
|
||||||
echo -n "Error: " >&2
|
echo -n "Error: " >&2
|
||||||
fi
|
fi
|
||||||
@ -90,6 +90,9 @@ then
|
|||||||
|
|
||||||
# The system Curl is too old for some modern HTTPS certificates on
|
# The system Curl is too old for some modern HTTPS certificates on
|
||||||
# older macOS versions.
|
# older macOS versions.
|
||||||
|
#
|
||||||
|
# Intentionally set this variable by exploding another.
|
||||||
|
# shellcheck disable=SC2086,SC2183
|
||||||
printf -v HOMEBREW_MACOS_VERSION_NUMERIC "%02d%02d%02d" ${HOMEBREW_MACOS_VERSION//./ }
|
printf -v HOMEBREW_MACOS_VERSION_NUMERIC "%02d%02d%02d" ${HOMEBREW_MACOS_VERSION//./ }
|
||||||
if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "101000" ]]
|
if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "101000" ]]
|
||||||
then
|
then
|
||||||
@ -162,6 +165,7 @@ export HOMEBREW_CACHE
|
|||||||
export HOMEBREW_CELLAR
|
export HOMEBREW_CELLAR
|
||||||
export HOMEBREW_SYSTEM
|
export HOMEBREW_SYSTEM
|
||||||
export HOMEBREW_CURL
|
export HOMEBREW_CURL
|
||||||
|
export HOMEBREW_SYSTEM_CURL_TOO_OLD
|
||||||
export HOMEBREW_GIT
|
export HOMEBREW_GIT
|
||||||
export HOMEBREW_PROCESSOR
|
export HOMEBREW_PROCESSOR
|
||||||
export HOMEBREW_PRODUCT
|
export HOMEBREW_PRODUCT
|
||||||
@ -340,8 +344,8 @@ access to all bottles."
|
|||||||
EOS
|
EOS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Hide shellcheck complaint:
|
# Don't need shellcheck to follow this `source`.
|
||||||
# shellcheck source=/dev/null
|
# shellcheck disable=SC1090
|
||||||
source "$HOMEBREW_LIBRARY/Homebrew/utils/analytics.sh"
|
source "$HOMEBREW_LIBRARY/Homebrew/utils/analytics.sh"
|
||||||
setup-analytics
|
setup-analytics
|
||||||
|
|
||||||
@ -401,13 +405,13 @@ then
|
|||||||
# a Ruby script and avoids hard-to-debug issues if the Bash script is updated
|
# a Ruby script and avoids hard-to-debug issues if the Bash script is updated
|
||||||
# at the same time as being run.
|
# at the same time as being run.
|
||||||
#
|
#
|
||||||
# Hide shellcheck complaint:
|
# Don't need shellcheck to follow this `source`.
|
||||||
# shellcheck source=/dev/null
|
# shellcheck disable=SC1090
|
||||||
source "$HOMEBREW_BASH_COMMAND"
|
source "$HOMEBREW_BASH_COMMAND"
|
||||||
{ update-preinstall; "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; }
|
{ update-preinstall; "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; }
|
||||||
else
|
else
|
||||||
# Hide shellcheck complaint:
|
# Don't need shellcheck to follow this `source`.
|
||||||
# shellcheck source=/dev/null
|
# shellcheck disable=SC1090
|
||||||
source "$HOMEBREW_LIBRARY/Homebrew/utils/ruby.sh"
|
source "$HOMEBREW_LIBRARY/Homebrew/utils/ruby.sh"
|
||||||
setup-ruby-path
|
setup-ruby-path
|
||||||
|
|
||||||
|
@ -26,12 +26,12 @@ homebrew-update-reset() {
|
|||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$REPOS" ]]
|
if [[ -z "${REPOS[]}" ]]
|
||||||
then
|
then
|
||||||
REPOS+=("$HOMEBREW_REPOSITORY" "$HOMEBREW_LIBRARY"/Taps/*/*)
|
REPOS+=("$HOMEBREW_REPOSITORY" "$HOMEBREW_LIBRARY"/Taps/*/*)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for DIR in ${REPOS[@]}
|
for DIR in "${REPOS[@]}"
|
||||||
do
|
do
|
||||||
[[ -d "$DIR/.git" ]] || continue
|
[[ -d "$DIR/.git" ]] || continue
|
||||||
cd "$DIR" || continue
|
cd "$DIR" || continue
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
#: If `--force` (or `-f`) is specified then always do a slower, full update check even
|
#: If `--force` (or `-f`) is specified then always do a slower, full update check even
|
||||||
#: if unnecessary.
|
#: if unnecessary.
|
||||||
|
|
||||||
# Hide shellcheck complaint:
|
# Don't need shellcheck to follow this `source`.
|
||||||
# shellcheck source=/dev/null
|
# shellcheck disable=SC1090
|
||||||
source "$HOMEBREW_LIBRARY/Homebrew/utils/lock.sh"
|
source "$HOMEBREW_LIBRARY/Homebrew/utils/lock.sh"
|
||||||
|
|
||||||
# Replaces the function in Library/Homebrew/brew.sh to cache the Git executable to
|
# Replaces the function in Library/Homebrew/brew.sh to cache the Git executable to
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
#: * `vendor-install` [<target>]:
|
#: * `vendor-install` [<target>]:
|
||||||
#: Install vendor version of Homebrew dependencies.
|
#: Install vendor version of Homebrew dependencies.
|
||||||
|
|
||||||
# Hide shellcheck complaint:
|
# Don't need shellcheck to follow this `source`.
|
||||||
# shellcheck source=/dev/null
|
# shellcheck disable=SC1090
|
||||||
source "$HOMEBREW_LIBRARY/Homebrew/utils/lock.sh"
|
source "$HOMEBREW_LIBRARY/Homebrew/utils/lock.sh"
|
||||||
|
|
||||||
VENDOR_DIR="$HOMEBREW_LIBRARY/Homebrew/vendor"
|
VENDOR_DIR="$HOMEBREW_LIBRARY/Homebrew/vendor"
|
||||||
|
|
||||||
# Built from https://github.com/Homebrew/homebrew-portable-ruby.
|
# Built from https://github.com/Homebrew/homebrew-portable-ruby.
|
||||||
|
#
|
||||||
|
# Dynamic variables can't be detected by shellcheck
|
||||||
|
# shellcheck disable=SC2034
|
||||||
if [[ -n "$HOMEBREW_MACOS" ]]
|
if [[ -n "$HOMEBREW_MACOS" ]]
|
||||||
then
|
then
|
||||||
if [[ "$HOMEBREW_PROCESSOR" = "Intel" ]]
|
if [[ "$HOMEBREW_PROCESSOR" = "Intel" ]]
|
||||||
@ -152,7 +155,6 @@ EOS
|
|||||||
|
|
||||||
install() {
|
install() {
|
||||||
local tar_args
|
local tar_args
|
||||||
local verb
|
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_VERBOSE" ]]
|
if [[ -n "$HOMEBREW_VERBOSE" ]]
|
||||||
then
|
then
|
||||||
@ -168,13 +170,7 @@ install() {
|
|||||||
|
|
||||||
if [[ -d "$VENDOR_VERSION" ]]
|
if [[ -d "$VENDOR_VERSION" ]]
|
||||||
then
|
then
|
||||||
verb="reinstall"
|
|
||||||
mv "$VENDOR_VERSION" "$VENDOR_VERSION.reinstall"
|
mv "$VENDOR_VERSION" "$VENDOR_VERSION.reinstall"
|
||||||
elif [[ -n "$(ls -A .)" ]]
|
|
||||||
then
|
|
||||||
verb="upgrade"
|
|
||||||
else
|
|
||||||
verb="install"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
safe_cd "$VENDOR_DIR"
|
safe_cd "$VENDOR_DIR"
|
||||||
@ -185,8 +181,6 @@ install() {
|
|||||||
if quiet_stderr "./$VENDOR_VERSION/bin/$VENDOR_NAME" --version >/dev/null
|
if quiet_stderr "./$VENDOR_VERSION/bin/$VENDOR_NAME" --version >/dev/null
|
||||||
then
|
then
|
||||||
ln -sfn "$VENDOR_VERSION" current
|
ln -sfn "$VENDOR_VERSION" current
|
||||||
# remove old vendor installations by sorting files with modified time.
|
|
||||||
ls -t | grep -Ev "^(current|$VENDOR_VERSION)" | tail -n +4 | xargs rm -rf
|
|
||||||
if [[ -d "$VENDOR_VERSION.reinstall" ]]
|
if [[ -d "$VENDOR_VERSION.reinstall" ]]
|
||||||
then
|
then
|
||||||
rm -rf "$VENDOR_VERSION.reinstall"
|
rm -rf "$VENDOR_VERSION.reinstall"
|
||||||
@ -197,7 +191,7 @@ install() {
|
|||||||
then
|
then
|
||||||
mv "$VENDOR_VERSION.reinstall" "$VENDOR_VERSION"
|
mv "$VENDOR_VERSION.reinstall" "$VENDOR_VERSION"
|
||||||
fi
|
fi
|
||||||
odie "Failed to $verb vendor $VENDOR_NAME."
|
odie "Failed to vendor $VENDOR_NAME $VENDOR_VERSION."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trap - SIGINT
|
trap - SIGINT
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
# Migrate analytics UUID to its new home in Homebrew repo's git config and
|
# Migrate analytics UUID to its new home in Homebrew repo's git config and
|
||||||
# remove the legacy UUID file if detected.
|
# remove the legacy UUID file if detected.
|
||||||
migrate-legacy-uuid-file() {
|
migrate-legacy-uuid-file() {
|
||||||
local legacy_uuid_file="$HOME/.homebrew_analytics_user_uuid"
|
local legacy_uuid_file analytics_uuid
|
||||||
|
|
||||||
|
legacy_uuid_file="$HOME/.homebrew_analytics_user_uuid"
|
||||||
|
|
||||||
if [[ -f "$legacy_uuid_file" ]]
|
if [[ -f "$legacy_uuid_file" ]]
|
||||||
then
|
then
|
||||||
local analytics_uuid="$(<"$legacy_uuid_file")"
|
analytics_uuid="$(<"$legacy_uuid_file")"
|
||||||
if [[ -n "$analytics_uuid" ]]
|
if [[ -n "$analytics_uuid" ]]
|
||||||
then
|
then
|
||||||
git config --file="$HOMEBREW_REPOSITORY/.git/config" --replace-all homebrew.analyticsuuid "$analytics_uuid" 2>/dev/null
|
git config --file="$HOMEBREW_REPOSITORY/.git/config" --replace-all homebrew.analyticsuuid "$analytics_uuid" 2>/dev/null
|
||||||
@ -23,8 +26,9 @@ setup-analytics() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local message_seen="$(git config --file="$git_config_file" --get homebrew.analyticsmessage 2>/dev/null)"
|
local message_seen analytics_disabled
|
||||||
local analytics_disabled="$(git config --file="$git_config_file" --get homebrew.analyticsdisabled 2>/dev/null)"
|
message_seen="$(git config --file="$git_config_file" --get homebrew.analyticsmessage 2>/dev/null)"
|
||||||
|
analytics_disabled="$(git config --file="$git_config_file" --get homebrew.analyticsdisabled 2>/dev/null)"
|
||||||
if [[ "$message_seen" != "true" || "$analytics_disabled" = "true" ]]
|
if [[ "$message_seen" != "true" || "$analytics_disabled" = "true" ]]
|
||||||
then
|
then
|
||||||
# Internal variable for brew's use, to differentiate from user-supplied setting
|
# Internal variable for brew's use, to differentiate from user-supplied setting
|
||||||
|
9
bin/brew
9
bin/brew
@ -8,12 +8,13 @@ if ! [[ -d "$PWD" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
quiet_cd() {
|
quiet_cd() {
|
||||||
cd "$@" >/dev/null
|
cd "$@" >/dev/null || return
|
||||||
}
|
}
|
||||||
|
|
||||||
symlink_target_directory() {
|
symlink_target_directory() {
|
||||||
local target="$(readlink "$1")"
|
local target target_dirname
|
||||||
local target_dirname="$(dirname "$target")"
|
target="$(readlink "$1")"
|
||||||
|
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
|
||||||
}
|
}
|
||||||
@ -83,5 +84,7 @@ then
|
|||||||
|
|
||||||
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
|
||||||
|
# Don't need shellcheck to follow this `source`.
|
||||||
|
# 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