style: fix inconsistent code style for shell scripts

This commit is contained in:
XuehaiPan 2021-09-13 20:32:20 +08:00
parent 9c03493774
commit 3f96d963f7
43 changed files with 421 additions and 331 deletions

View File

@ -34,11 +34,11 @@ jobs:
- name: Deploy the tagged Docker image to GitHub Packages
if: startsWith(github.ref, 'refs/tags/')
run: |
brew_version=${GITHUB_REF:10}
echo "brew_version=$brew_version" >> ${GITHUB_ENV}
brew_version="${GITHUB_REF:10}"
echo "brew_version=${brew_version}" >> "${GITHUB_ENV}"
echo ${{secrets.HOMEBREW_BREW_GITHUB_PACKAGES_TOKEN}} | docker login ghcr.io -u BrewTestBot --password-stdin
docker tag brew "ghcr.io/homebrew/ubuntu${{matrix.version}}:$brew_version"
docker push "ghcr.io/homebrew/ubuntu${{matrix.version}}:$brew_version"
docker tag brew "ghcr.io/homebrew/ubuntu${{matrix.version}}:${brew_version}"
docker push "ghcr.io/homebrew/ubuntu${{matrix.version}}:${brew_version}"
docker tag brew "ghcr.io/homebrew/ubuntu${{matrix.version}}:latest"
docker push "ghcr.io/homebrew/ubuntu${{matrix.version}}:latest"
@ -46,19 +46,19 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
run: |
echo ${{secrets.HOMEBREW_BREW_DOCKER_TOKEN}} | docker login -u brewtestbot --password-stdin
docker tag brew "homebrew/ubuntu${{matrix.version}}:$brew_version"
docker push "homebrew/ubuntu${{matrix.version}}:$brew_version"
docker tag brew "homebrew/ubuntu${{matrix.version}}:${brew_version}"
docker push "homebrew/ubuntu${{matrix.version}}:${brew_version}"
docker tag brew "homebrew/ubuntu${{matrix.version}}:latest"
docker push "homebrew/ubuntu${{matrix.version}}:latest"
- name: Deploy the homebrew/brew Docker image to GitHub Packages and Docker Hub
if: startsWith(github.ref, 'refs/tags/') && matrix.version == '20.04'
run: |
docker tag brew "ghcr.io/homebrew/brew:$brew_version"
docker push "ghcr.io/homebrew/brew:$brew_version"
docker tag brew "ghcr.io/homebrew/brew:${brew_version}"
docker push "ghcr.io/homebrew/brew:${brew_version}"
docker tag brew "ghcr.io/homebrew/brew:latest"
docker push "ghcr.io/homebrew/brew:latest"
docker tag brew "homebrew/brew:$brew_version"
docker push "homebrew/brew:$brew_version"
docker tag brew "homebrew/brew:${brew_version}"
docker push "homebrew/brew:${brew_version}"
docker tag brew "homebrew/brew:latest"
docker push "homebrew/brew:latest"

View File

@ -40,20 +40,23 @@ jobs:
BRANCH="sorbet-files-update"
echo "::set-output name=branch::${BRANCH}"
if git ls-remote --exit-code --heads origin "$BRANCH"; then
git checkout "$BRANCH"
if git ls-remote --exit-code --heads origin "${BRANCH}"
then
git checkout "${BRANCH}"
git reset --hard origin/master
else
git checkout --no-track -B "$BRANCH" origin/master
git checkout --no-track -B "${BRANCH}" origin/master
fi
if brew typecheck --update --fail-if-not-changed; then
git add "$GITHUB_WORKSPACE/Library/Homebrew/sorbet"
if brew typecheck --update --fail-if-not-changed
then
git add "${GITHUB_WORKSPACE}/Library/Homebrew/sorbet"
git commit -m "sorbet: Update RBI files." \
-m "Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow."
echo "::set-output name=committed::true"
PULL_REQUEST_STATE=$(gh pr view --json=state | jq -r ".state")
if [ "$PULL_REQUEST_STATE" != "OPEN" ]; then
PULL_REQUEST_STATE="$(gh pr view --json=state | jq -r ".state")"
if [[ "${PULL_REQUEST_STATE}" != "OPEN" ]]
then
echo "::set-output name=pull_request::true"
fi
fi

View File

@ -37,19 +37,22 @@ jobs:
BRANCH="spdx-update"
echo "::set-output name=branch::${BRANCH}"
if git ls-remote --exit-code --heads origin "$BRANCH"; then
git checkout "$BRANCH"
if git ls-remote --exit-code --heads origin "${BRANCH}"
then
git checkout "${BRANCH}"
git reset --hard origin/master
else
git checkout --no-track -B "$BRANCH" origin/master
git checkout --no-track -B "${BRANCH}" origin/master
fi
if brew update-license-data --fail-if-not-changed; then
git add "$GITHUB_WORKSPACE/Library/Homebrew/data/spdx"
if brew update-license-data --fail-if-not-changed
then
git add "${GITHUB_WORKSPACE}/Library/Homebrew/data/spdx"
git commit -m "spdx: update license data." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/spdx.yml)."
echo "::set-output name=committed::true"
PULL_REQUEST_STATE=$(gh pr view --json=state | jq -r ".state")
if [ "$PULL_REQUEST_STATE" != "OPEN" ]; then
PULL_REQUEST_STATE="$(gh pr view --json=state | jq -r ".state")"
if [[ "${PULL_REQUEST_STATE}" != "OPEN" ]]
then
echo "::set-output name=pull_request::true"
fi
fi

View File

@ -90,10 +90,10 @@ jobs:
- name: Set up all Homebrew taps
run: |
HOMEBREW_REPOSITORY="$(brew --repo)"
HOMEBREW_CORE_REPOSITORY="$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core"
git -C "$HOMEBREW_CORE_REPOSITORY" remote add homebrew_core https://github.com/Homebrew/homebrew-core
git -C "$HOMEBREW_CORE_REPOSITORY" fetch homebrew_core || git -C "$HOMEBREW_CORE_REPOSITORY" fetch homebrew_core
git -C "$HOMEBREW_CORE_REPOSITORY" checkout --force -B master homebrew_core/master
HOMEBREW_CORE_REPOSITORY="${HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-core"
git -C "${HOMEBREW_CORE_REPOSITORY}" remote add homebrew_core https://github.com/Homebrew/homebrew-core
git -C "${HOMEBREW_CORE_REPOSITORY}" fetch homebrew_core || git -C "${HOMEBREW_CORE_REPOSITORY}" fetch homebrew_core
git -C "${HOMEBREW_CORE_REPOSITORY}" checkout --force -B master homebrew_core/master
brew tap homebrew/aliases
brew tap homebrew/autoupdate
@ -111,7 +111,7 @@ jobs:
brew update-reset Library/Taps/homebrew/homebrew-bundle
# brew style doesn't like world writable directories
sudo chmod -R g-w,o-w "$HOMEBREW_REPOSITORY/Library/Taps"
sudo chmod -R g-w,o-w "${HOMEBREW_REPOSITORY}/Library/Taps"
- name: Run brew style on homebrew-core
run: brew style --display-cop-names homebrew/core
@ -178,11 +178,11 @@ jobs:
- name: Deploy the Docker image to GitHub Packages and Docker Hub
if: github.ref == 'refs/heads/master'
run: |
echo ${{secrets.HOMEBREW_BREW_GITHUB_PACKAGES_TOKEN}} | \
echo ${{secrets.HOMEBREW_BREW_GITHUB_PACKAGES_TOKEN}} |
docker login ghcr.io -u BrewTestBot --password-stdin
docker tag brew "ghcr.io/homebrew/ubuntu16.04:master"
docker push "ghcr.io/homebrew/ubuntu16.04:master"
echo ${{secrets.HOMEBREW_BREW_DOCKER_TOKEN}} | \
echo ${{secrets.HOMEBREW_BREW_DOCKER_TOKEN}} |
docker login -u brewtestbot --password-stdin
docker tag brew "homebrew/ubuntu16.04:master"
docker push "homebrew/ubuntu16.04:master"
@ -321,9 +321,10 @@ jobs:
run: |
# Retry multiple times when using BuildPulse to detect and submit
# flakiness (because rspec-retry is disabled).
if [ -n "$HOMEBREW_BUILDPULSE_ACCESS_KEY_ID" ]; then
brew tests --online --coverage || \
brew tests --online --coverage || \
if [[ -n "${HOMEBREW_BUILDPULSE_ACCESS_KEY_ID}" ]]
then
brew tests --online --coverage ||
brew tests --online --coverage ||
brew tests --online --coverage
else
brew tests --online --coverage

View File

@ -44,27 +44,31 @@ jobs:
BRANCH=update-man-completions
echo "::set-output name=branch::${BRANCH}"
if git ls-remote --exit-code --heads origin "$BRANCH"; then
git checkout "$BRANCH"
if git ls-remote --exit-code --heads origin "${BRANCH}"
then
git checkout "${BRANCH}"
git reset --hard origin/master
else
git checkout --no-track -B "$BRANCH" origin/master
git checkout --no-track -B "${BRANCH}" origin/master
fi
if [ "${{github.event_name}}" != "push" ]; then
if [[ "${{github.event_name}}" != "push" ]]
then
brew update-maintainers
fi
if brew generate-man-completions --fail-if-not-changed; then
git add "$GITHUB_WORKSPACE/README.md" \
"$GITHUB_WORKSPACE/docs/Manpage.md" \
"$GITHUB_WORKSPACE/manpages/brew.1" \
"$GITHUB_WORKSPACE/completions"
if brew generate-man-completions --fail-if-not-changed
then
git add "${GITHUB_WORKSPACE}/README.md" \
"${GITHUB_WORKSPACE}/docs/Manpage.md" \
"${GITHUB_WORKSPACE}/manpages/brew.1" \
"${GITHUB_WORKSPACE}/completions"
git commit -m "Update maintainers, manpage and completions." \
-m "Autogenerated by the [update-man-completions](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/update-man-completions.yml) workflow."
echo "::set-output name=committed::true"
PULL_REQUEST_STATE=$(gh pr view --json=state | jq -r ".state")
if [ "$PULL_REQUEST_STATE" != "OPEN" ]; then
PULL_REQUEST_STATE="$(gh pr view --json=state | jq -r ".state")"
if [[ "${PULL_REQUEST_STATE}" != "OPEN" ]]
then
echo "::set-output name=pull_request::true"
fi
fi

View File

@ -51,7 +51,8 @@ jobs:
run: |
set -u
if [[ "${GEM_NAME}" == 'sorbet' ]]; then
if [[ "${GEM_NAME}" == 'sorbet' ]]
then
brew vendor-gems --update sorbet,sorbet-runtime
else
brew vendor-gems
@ -63,8 +64,10 @@ jobs:
run: |
set -u
if brew typecheck --update --fail-if-not-changed; then
if git add Library/Homebrew/sorbet; then
if brew typecheck --update --fail-if-not-changed
then
if git add Library/Homebrew/sorbet
then
git commit -m "Update RBI files for ${GEM_NAME}."
fi

View File

@ -2,5 +2,5 @@
"ruby.rubocop.executePath": "Library/Homebrew/shims/gems/",
"files.trimTrailingWhitespace": true,
"editor.tabSize": 2,
"files.insertFinalNewline": true,
"files.insertFinalNewline": true
}

View File

@ -34,7 +34,7 @@ RUN apt-get update \
USER linuxbrew
COPY --chown=linuxbrew:linuxbrew . /home/linuxbrew/.linuxbrew/Homebrew
ENV PATH=/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH
ENV PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${PATH}"
WORKDIR /home/linuxbrew
RUN mkdir -p \

View File

@ -17,10 +17,11 @@ esac
# same file under the native architecture
# These variables are set from the user environment.
# shellcheck disable=SC2154
if [[ "${HOMEBREW_CHANGE_ARCH_TO_ARM}" = "1" ]] && \
[[ "${HOMEBREW_MACOS}" = "1" ]] && \
[[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" = "1" ]] && \
[[ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = "1" ]]; then
if [[ "${HOMEBREW_CHANGE_ARCH_TO_ARM}" == "1" ]] &&
[[ "${HOMEBREW_MACOS}" == "1" ]] &&
[[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" == "1" ]] &&
[[ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" == "1" ]]
then
exec arch -arm64e "${HOMEBREW_BREW_FILE}" "$@"
fi
@ -55,15 +56,15 @@ HOMEBREW_TEMP="${HOMEBREW_TEMP:-${HOMEBREW_DEFAULT_TEMP}}"
# HOMEBREW_LIBRARY set by bin/brew
# shellcheck disable=SC2249,SC2154
case "$*" in
--cellar) echo "${HOMEBREW_CELLAR}"; exit 0 ;;
--repository|--repo) echo "${HOMEBREW_REPOSITORY}"; exit 0 ;;
--caskroom) echo "${HOMEBREW_PREFIX}/Caskroom"; exit 0 ;;
--cache) echo "${HOMEBREW_CACHE}"; exit 0 ;;
shellenv) source "${HOMEBREW_LIBRARY}/Homebrew/cmd/shellenv.sh"; homebrew-shellenv; exit 0 ;;
formulae) source "${HOMEBREW_LIBRARY}/Homebrew/cmd/formulae.sh"; homebrew-formulae; exit 0 ;;
casks) source "${HOMEBREW_LIBRARY}/Homebrew/cmd/casks.sh"; homebrew-casks; exit 0 ;;
--cellar) echo "${HOMEBREW_CELLAR}"; exit 0 ;;
--repository | --repo) echo "${HOMEBREW_REPOSITORY}"; exit 0 ;;
--caskroom) echo "${HOMEBREW_PREFIX}/Caskroom"; exit 0 ;;
--cache) echo "${HOMEBREW_CACHE}"; exit 0 ;;
shellenv) source "${HOMEBREW_LIBRARY}/Homebrew/cmd/shellenv.sh"; homebrew-shellenv; exit 0 ;;
formulae) source "${HOMEBREW_LIBRARY}/Homebrew/cmd/formulae.sh"; homebrew-formulae; exit 0 ;;
casks) source "${HOMEBREW_LIBRARY}/Homebrew/cmd/casks.sh"; homebrew-casks; exit 0 ;;
# falls back to cmd/prefix.rb on a non-zero return
--prefix*) source "${HOMEBREW_LIBRARY}/Homebrew/prefix.sh"; homebrew-prefix "$@" && exit 0 ;;
--prefix*) source "${HOMEBREW_LIBRARY}/Homebrew/prefix.sh"; homebrew-prefix "$@" && exit 0 ;;
esac
#####
@ -144,16 +145,16 @@ numeric() {
}
check-run-command-as-root() {
[[ "$(id -u)" = 0 ]] || return
[[ "$(id -u)" == 0 ]] || return
# Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there)
[[ -f /proc/1/cgroup ]] && grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup && return
# Homebrew Services may need `sudo` for system-wide daemons.
[[ "${HOMEBREW_COMMAND}" = "services" ]] && return
[[ "${HOMEBREW_COMMAND}" == "services" ]] && return
# It's fine to run this as root as it's not changing anything.
[[ "${HOMEBREW_COMMAND}" = "--prefix" ]] && return
[[ "${HOMEBREW_COMMAND}" == "--prefix" ]] && return
odie <<EOS
Running Homebrew as root is extremely dangerous and no longer supported.
@ -165,7 +166,7 @@ EOS
check-prefix-is-not-tmpdir() {
[[ -z "${HOMEBREW_MACOS}" ]] && return
if [[ "${HOMEBREW_PREFIX}" = "${HOMEBREW_TEMP}"* ]]
if [[ "${HOMEBREW_PREFIX}" == "${HOMEBREW_TEMP}"* ]]
then
odie <<EOS
Your HOMEBREW_PREFIX is in the Homebrew temporary directory, which Homebrew
@ -195,10 +196,13 @@ update-preinstall() {
# If we've checked for updates, we don't need to check again.
export HOMEBREW_AUTO_UPDATE_CHECKED="1"
if [[ "${HOMEBREW_COMMAND}" = "install" || "${HOMEBREW_COMMAND}" = "upgrade" ||
"${HOMEBREW_COMMAND}" = "bump-formula-pr" || "${HOMEBREW_COMMAND}" = "bump-cask-pr" ||
"${HOMEBREW_COMMAND}" = "bundle" || "${HOMEBREW_COMMAND}" = "release" ||
"${HOMEBREW_COMMAND}" = "tap" && ${HOMEBREW_ARG_COUNT} -gt 1 ]]
if [[ "${HOMEBREW_COMMAND}" == "install" ]] ||
[[ "${HOMEBREW_COMMAND}" == "upgrade" ]] ||
[[ "${HOMEBREW_COMMAND}" == "bump-formula-pr" ]] ||
[[ "${HOMEBREW_COMMAND}" == "bump-cask-pr" ]] ||
[[ "${HOMEBREW_COMMAND}" == "bundle" ]] ||
[[ "${HOMEBREW_COMMAND}" == "release" ]] ||
[[ "${HOMEBREW_COMMAND}" == "tap" && "${HOMEBREW_ARG_COUNT}" -gt 1 ]]
then
export HOMEBREW_AUTO_UPDATING="1"
@ -210,8 +214,8 @@ update-preinstall() {
# Skip auto-update if the repository has been updated in the
# last $HOMEBREW_AUTO_UPDATE_SECS.
repo_fetch_head="${HOMEBREW_REPOSITORY}/.git/FETCH_HEAD"
if [[ -f "${repo_fetch_head}" &&
-n "$(find "${repo_fetch_head}" -type f -mtime -"${HOMEBREW_AUTO_UPDATE_SECS}"s 2>/dev/null)" ]]
if [[ -f "${repo_fetch_head}" ]] &&
[[ -n "$(find "${repo_fetch_head}" -type f -mtime -"${HOMEBREW_AUTO_UPDATE_SECS}"s 2>/dev/null)" ]]
then
return
fi
@ -244,7 +248,8 @@ update-preinstall() {
# Colorize output on GitHub Actions.
# This is set by the user environment.
# shellcheck disable=SC2154
if [[ -n "${GITHUB_ACTIONS}" ]]; then
if [[ -n "${GITHUB_ACTIONS}" ]]
then
export HOMEBREW_COLOR="1"
fi
@ -261,13 +266,13 @@ else
export LC_ALL=C
elif [[ "$(locale charmap)" != "UTF-8" ]]
then
locales=$(locale -a)
locales="$(locale -a)"
c_utf_regex='\bC\.(utf8|UTF-8)\b'
en_us_regex='\ben_US\.(utf8|UTF-8)\b'
utf_regex='\b[a-z][a-z]_[A-Z][A-Z]\.(utf8|UTF-8)\b'
if [[ ${locales} =~ ${c_utf_regex} || ${locales} =~ ${en_us_regex} || ${locales} =~ ${utf_regex} ]]
then
export LC_ALL=${BASH_REMATCH[0]}
export LC_ALL="${BASH_REMATCH[0]}"
else
export LC_ALL=C
fi
@ -278,7 +283,7 @@ fi
##### odie as quickly as possible.
#####
if [[ "${HOMEBREW_PREFIX}" = "/" || "${HOMEBREW_PREFIX}" = "/usr" ]]
if [[ "${HOMEBREW_PREFIX}" == "/" || "${HOMEBREW_PREFIX}" == "/usr" ]]
then
# it may work, but I only see pain this route and don't want to support it
odie "Cowardly refusing to continue at this prefix: ${HOMEBREW_PREFIX}"
@ -296,17 +301,16 @@ fi
#####
# USER isn't always set so provide a fall back for `brew` and subprocesses.
export USER=${USER:-$(id -un)}
export USER="${USER:-$(id -un)}"
# A depth of 1 means this command was directly invoked by a user.
# Higher depths mean this command was invoked by another Homebrew command.
export HOMEBREW_COMMAND_DEPTH=$((HOMEBREW_COMMAND_DEPTH + 1))
export HOMEBREW_COMMAND_DEPTH="$((HOMEBREW_COMMAND_DEPTH + 1))"
# This is set by the user environment.
# shellcheck disable=SC2154
if [[ -n "${HOMEBREW_FORCE_BREWED_CURL}" &&
-x "${HOMEBREW_PREFIX}/opt/curl/bin/curl" ]] &&
"${HOMEBREW_PREFIX}/opt/curl/bin/curl" --version >/dev/null
if [[ -n "${HOMEBREW_FORCE_BREWED_CURL}" && -x "${HOMEBREW_PREFIX}/opt/curl/bin/curl" ]] &&
"${HOMEBREW_PREFIX}/opt/curl/bin/curl" --version >/dev/null
then
HOMEBREW_CURL="${HOMEBREW_PREFIX}/opt/curl/bin/curl"
elif [[ -n "${HOMEBREW_DEVELOPER}" && -x "${HOMEBREW_CURL_PATH}" ]]
@ -318,9 +322,8 @@ fi
# This is set by the user environment.
# shellcheck disable=SC2154
if [[ -n "${HOMEBREW_FORCE_BREWED_GIT}" &&
-x "${HOMEBREW_PREFIX}/opt/git/bin/git" ]] &&
"${HOMEBREW_PREFIX}/opt/git/bin/git" --version >/dev/null
if [[ -n "${HOMEBREW_FORCE_BREWED_GIT}" && -x "${HOMEBREW_PREFIX}/opt/git/bin/git" ]] &&
"${HOMEBREW_PREFIX}/opt/git/bin/git" --version >/dev/null
then
HOMEBREW_GIT="${HOMEBREW_PREFIX}/opt/git/bin/git"
elif [[ -n "${HOMEBREW_DEVELOPER}" && -x "${HOMEBREW_GIT_PATH}" ]]
@ -344,7 +347,11 @@ HOMEBREW_CORE_REPOSITORY="${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core"
HOMEBREW_CASK_REPOSITORY="${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask"
case "$*" in
--version|-v) source "${HOMEBREW_LIBRARY}/Homebrew/cmd/--version.sh"; homebrew-version; exit 0 ;;
--version | -v)
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/--version.sh"
homebrew-version
exit 0
;;
esac
# shellcheck disable=SC2154
@ -357,7 +364,7 @@ if [[ -n "${HOMEBREW_MACOS}" ]]
then
HOMEBREW_PRODUCT="Homebrew"
HOMEBREW_SYSTEM="Macintosh"
[[ "${HOMEBREW_PROCESSOR}" = "x86_64" ]] && HOMEBREW_PROCESSOR="Intel"
[[ "${HOMEBREW_PROCESSOR}" == "x86_64" ]] && HOMEBREW_PROCESSOR="Intel"
HOMEBREW_MACOS_VERSION="$(/usr/bin/sw_vers -productVersion)"
# Don't change this from Mac OS X to match what macOS itself does in Safari on 10.12
HOMEBREW_OS_USER_AGENT_VERSION="Mac OS X ${HOMEBREW_MACOS_VERSION}"
@ -423,17 +430,19 @@ else
curl_version_output="$(${HOMEBREW_CURL} --version 2>/dev/null)"
curl_name_and_version="${curl_version_output%% (*}"
# shellcheck disable=SC2248
if [[ $(numeric "${curl_name_and_version##* }") -lt $(numeric "${HOMEBREW_MINIMUM_CURL_VERSION}") ]]
if [[ "$(numeric "${curl_name_and_version##* }")" -lt "$(numeric "${HOMEBREW_MINIMUM_CURL_VERSION}")" ]]
then
message="Please update your system curl.
message="Please update your system curl.
Minimum required version: ${HOMEBREW_MINIMUM_CURL_VERSION}
Your curl version: ${curl_name_and_version##* }
Your curl executable: $(type -p ${HOMEBREW_CURL})"
if [[ -z ${HOMEBREW_CURL_PATH} || -z ${HOMEBREW_DEVELOPER} ]]; then
if [[ -z ${HOMEBREW_CURL_PATH} || -z ${HOMEBREW_DEVELOPER} ]]
then
HOMEBREW_SYSTEM_CURL_TOO_OLD=1
HOMEBREW_FORCE_BREWED_CURL=1
if [[ -z ${HOMEBREW_CURL_WARNING} ]]; then
if [[ -z ${HOMEBREW_CURL_WARNING} ]]
then
onoe "${message}"
HOMEBREW_CURL_WARNING=1
fi
@ -448,17 +457,19 @@ Your curl executable: $(type -p ${HOMEBREW_CURL})"
git_version_output="$(${HOMEBREW_GIT} --version 2>/dev/null)"
# $extra is intentionally discarded.
# shellcheck disable=SC2034
IFS=. read -r major minor micro build extra <<< "${git_version_output##* }"
IFS='.' read -r major minor micro build extra <<<"${git_version_output##* }"
# shellcheck disable=SC2248
if [[ $(numeric "${major}.${minor}.${micro}.${build}") -lt $(numeric "${HOMEBREW_MINIMUM_GIT_VERSION}") ]]
if [[ "$(numeric "${major}.${minor}.${micro}.${build}")" -lt "$(numeric "${HOMEBREW_MINIMUM_GIT_VERSION}")" ]]
then
message="Please update your system Git.
Minimum required version: ${HOMEBREW_MINIMUM_GIT_VERSION}
Your Git version: ${major}.${minor}.${micro}.${build}
Your Git executable: $(unset git && type -p ${HOMEBREW_GIT})"
if [[ -z ${HOMEBREW_GIT_PATH} || -z ${HOMEBREW_DEVELOPER} ]]; then
if [[ -z ${HOMEBREW_GIT_PATH} || -z ${HOMEBREW_DEVELOPER} ]]
then
HOMEBREW_FORCE_BREWED_GIT="1"
if [[ -z ${HOMEBREW_GIT_WARNING} ]]; then
if [[ -z ${HOMEBREW_GIT_WARNING} ]]
then
onoe "${message}"
HOMEBREW_GIT_WARNING=1
fi
@ -471,7 +482,7 @@ Your Git executable: $(unset git && type -p ${HOMEBREW_GIT})"
unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
HOMEBREW_CORE_REPOSITORY_ORIGIN="$("${HOMEBREW_GIT}" -C "${HOMEBREW_CORE_REPOSITORY}" remote get-url origin)"
if [[ "${HOMEBREW_CORE_REPOSITORY_ORIGIN}" = "https://github.com/Homebrew/homebrew-core" ]]
if [[ "${HOMEBREW_CORE_REPOSITORY_ORIGIN}" == "https://github.com/Homebrew/homebrew-core" ]]
then
# If the remote origin has been set to Homebrew/homebrew-core by the install script,
# then we are in the case of a new installation of brew, using Homebrew/homebrew-core as a Linux core repository.
@ -490,12 +501,15 @@ fi
# That will be when macOS 12 is the minimum required version.
# HOMEBREW_BOTTLE_DOMAIN is set from the user environment
# shellcheck disable=SC2154
if [[ -n "${HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" && "${HOMEBREW_BOTTLE_DOMAIN}" = "${HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" ]]
if [[ -n "${HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" ]] &&
[[ "${HOMEBREW_BOTTLE_DOMAIN}" == "${HOMEBREW_BOTTLE_DEFAULT_DOMAIN}" ]]
then
unset HOMEBREW_BOTTLE_DOMAIN
fi
if [[ -n "${HOMEBREW_MACOS}" || -n "${HOMEBREW_FORCE_HOMEBREW_ON_LINUX}" || -n "${HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX}" ]]
if [[ -n "${HOMEBREW_MACOS}" ]] ||
[[ -n "${HOMEBREW_FORCE_HOMEBREW_ON_LINUX}" ]] ||
[[ -n "${HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX}" ]]
then
HOMEBREW_BOTTLE_DEFAULT_DOMAIN="https://ghcr.io/v2/homebrew/core"
else
@ -535,8 +549,8 @@ export HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
if [[ -n "${HOMEBREW_MACOS}" && -x "/usr/bin/xcode-select" ]]
then
XCODE_SELECT_PATH=$('/usr/bin/xcode-select' --print-path 2>/dev/null)
if [[ "${XCODE_SELECT_PATH}" = "/" ]]
XCODE_SELECT_PATH="$('/usr/bin/xcode-select' --print-path 2>/dev/null)"
if [[ "${XCODE_SELECT_PATH}" == "/" ]]
then
odie <<EOS
Your xcode-select path is currently set to '/'.
@ -555,7 +569,7 @@ EOS
XCRUN_OUTPUT="$(/usr/bin/xcrun clang 2>&1)"
XCRUN_STATUS="$?"
if [[ "${XCRUN_STATUS}" -ne 0 && "${XCRUN_OUTPUT}" = *license* ]]
if [[ "${XCRUN_STATUS}" -ne 0 && "${XCRUN_OUTPUT}" == *license* ]]
then
odie <<EOS
You have not agreed to the Xcode license. Please resolve this by running:
@ -565,7 +579,7 @@ EOS
fi
fi
if [[ "$1" = -v ]]
if [[ "$1" == "-v" ]]
then
# Shift the -v to the end of the parameter list
shift
@ -574,9 +588,9 @@ fi
for arg in "$@"
do
[[ ${arg} = "--" ]] && break
[[ "${arg}" == "--" ]] && break
if [[ ${arg} = "--help" || ${arg} = "-h" || ${arg} = "--usage" || ${arg} = "-?" ]]
if [[ "${arg}" == "--help" || "${arg}" == "-h" || "${arg}" == "--usage" || "${arg}" == "-?" ]]
then
export HOMEBREW_HELP="1"
break
@ -611,7 +625,7 @@ if [[ -z "${HOMEBREW_DEVELOPER}" ]]
then
export HOMEBREW_GIT_CONFIG_FILE="${HOMEBREW_REPOSITORY}/.git/config"
HOMEBREW_GIT_CONFIG_DEVELOPERMODE="$(git config --file="${HOMEBREW_GIT_CONFIG_FILE}" --get homebrew.devcmdrun 2>/dev/null)"
if [[ "${HOMEBREW_GIT_CONFIG_DEVELOPERMODE}" = "true" ]]
if [[ "${HOMEBREW_GIT_CONFIG_DEVELOPERMODE}" == "true" ]]
then
export HOMEBREW_DEV_CMD_RUN="1"
fi
@ -635,7 +649,9 @@ then
fi
export HOMEBREW_BREW_GIT_REMOTE
if [[ -n "${HOMEBREW_MACOS}" ]] || [[ -n "${HOMEBREW_FORCE_HOMEBREW_ON_LINUX}" ]] || [[ -n "${HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX}" ]]
if [[ -n "${HOMEBREW_MACOS}" ]] ||
[[ -n "${HOMEBREW_FORCE_HOMEBREW_ON_LINUX}" ]] ||
[[ -n "${HOMEBREW_FORCE_HOMEBREW_CORE_REPO_ON_LINUX}" ]]
then
HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
else
@ -676,9 +692,9 @@ check-run-command-as-root
check-prefix-is-not-tmpdir
# shellcheck disable=SC2250
if [[ "${HOMEBREW_PREFIX}" = "/usr/local" &&
"${HOMEBREW_PREFIX}" != "${HOMEBREW_REPOSITORY}" &&
"${HOMEBREW_CELLAR}" = "${HOMEBREW_REPOSITORY}/Cellar" ]]
if [[ "${HOMEBREW_PREFIX}" == "/usr/local" ]] &&
[[ "${HOMEBREW_PREFIX}" != "${HOMEBREW_REPOSITORY}" ]] &&
[[ "${HOMEBREW_CELLAR}" == "${HOMEBREW_REPOSITORY}/Cellar" ]]
then
cat >&2 <<EOS
Warning: your HOMEBREW_PREFIX is set to /usr/local but HOMEBREW_CELLAR is set
@ -702,7 +718,13 @@ then
# Shellcheck can't follow this dynamic `source`.
# shellcheck disable=SC1090
source "${HOMEBREW_BASH_COMMAND}"
{ update-preinstall "$@"; "homebrew-${HOMEBREW_COMMAND}" "$@"; exit $?; }
{
update-preinstall "$@"
"homebrew-${HOMEBREW_COMMAND}" "$@"
exit $?
}
else
source "${HOMEBREW_LIBRARY}/Homebrew/utils/ruby.sh"
setup-ruby-path
@ -711,5 +733,9 @@ else
[[ "${HOMEBREW_ARG_COUNT}" -gt 0 ]] && set -- "${HOMEBREW_COMMAND}" "$@"
# HOMEBREW_RUBY_PATH set by utils/ruby.sh
# shellcheck disable=SC2154
{ update-preinstall "$@"; exec "${HOMEBREW_RUBY_PATH}" "${HOMEBREW_RUBY_WARNINGS}" "${RUBY_DISABLE_OPTIONS}" "${HOMEBREW_LIBRARY}/Homebrew/brew.rb" "$@"; }
{
update-preinstall "$@"
exec "${HOMEBREW_RUBY_PATH}" "${HOMEBREW_RUBY_WARNINGS}" "${RUBY_DISABLE_OPTIONS}" \
"${HOMEBREW_LIBRARY}/Homebrew/brew.rb" "$@"
}
fi

View File

@ -4,34 +4,41 @@ set -euo pipefail
# Try removing as many empty directories as possible with a single
# `rmdir` call to avoid or at least speed up the loop below.
if /bin/rmdir -- "${@}" &>/dev/null; then
if /bin/rmdir -- "${@}" &>/dev/null
then
exit
fi
for path in "${@}"; do
for path in "${@}"
do
symlink=true
[[ -L "${path}" ]] || symlink=false
directory=false
if [[ -d "${path}" ]]; then
if [[ -d "${path}" ]]
then
directory=true
if [[ -e "${path}/.DS_Store" ]]; then
if [[ -e "${path}/.DS_Store" ]]
then
/bin/rm -- "${path}/.DS_Store"
fi
# Some packages leave broken symlinks around; we clean them out before
# attempting to `rmdir` to prevent extra cruft from accumulating.
/usr/bin/find -f "${path}" -- -mindepth 1 -maxdepth 1 -type l ! -exec /bin/test -e {} \; -delete
elif ! ${symlink} && [[ ! -e "${path}" ]]; then
elif ! ${symlink} && [[ ! -e "${path}" ]]
then
# Skip paths that don't exists and aren't a broken symlink.
continue
fi
if ${symlink}; then
if ${symlink}
then
# Delete directory symlink.
/bin/rm -- "${path}"
elif ${directory}; then
elif ${directory}
then
# Delete directory if empty.
/usr/bin/find -f "${path}" -- -maxdepth 0 -type d -empty -exec /bin/rmdir -- {} \;
else

View File

@ -6,20 +6,22 @@
# shellcheck disable=SC2154
version_string() {
local repo="$1"
if ! [ -d "${repo}" ]; then
if ! [[ -d "${repo}" ]]
then
echo "N/A"
return
fi
local pretty_revision
pretty_revision="$(git -C "${repo}" rev-parse --short --verify --quiet HEAD)"
if [ -z "${pretty_revision}" ]; then
if [[ -z "${pretty_revision}" ]]
then
echo "(no Git repository)"
return
fi
local git_last_commit_date
git_last_commit_date=$(git -C "${repo}" show -s --format='%cd' --date=short HEAD)
git_last_commit_date="$(git -C "${repo}" show -s --format='%cd' --date=short HEAD)"
echo "(git revision ${pretty_revision}; last commit ${git_last_commit_date})"
}
@ -27,7 +29,8 @@ homebrew-version() {
echo "Homebrew ${HOMEBREW_VERSION}"
echo "Homebrew/homebrew-core $(version_string "${HOMEBREW_CORE_REPOSITORY}")"
if [ -d "${HOMEBREW_CASK_REPOSITORY}" ]; then
if [[ -d "${HOMEBREW_CASK_REPOSITORY}" ]]
then
echo "Homebrew/homebrew-cask $(version_string "${HOMEBREW_CASK_REPOSITORY}")"
fi
}

View File

@ -4,14 +4,14 @@
#:
#: The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
#: The variable `HOMEBREW_SHELLENV_PREFIX` will be exported to avoid adding duplicate entries to the environment variables.
#: Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval $(brew shellenv)`
#: Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval "$(brew shellenv)"`
# HOMEBREW_CELLAR and HOMEBREW_PREFIX are set by extend/ENV/super.rb
# HOMEBREW_REPOSITORY is set by bin/brew
# shellcheck disable=SC2154
homebrew-shellenv() {
[[ "${HOMEBREW_SHELLENV_PREFIX}" == "${HOMEBREW_PREFIX}" &&
"$(PATH="${HOMEBREW_PATH}" command -v brew)" == "${HOMEBREW_PREFIX}/bin/brew" ]] && return
[[ "${HOMEBREW_SHELLENV_PREFIX}" == "${HOMEBREW_PREFIX}" ]] &&
[[ "$(PATH="${HOMEBREW_PATH}" command -v brew)" == "${HOMEBREW_PREFIX}/bin/brew" ]] && return
case "$(/bin/ps -p "${PPID}" -c -o comm=)" in
fish | -fish)

View File

@ -11,10 +11,10 @@ homebrew-update-reset() {
for option in "$@"
do
case "${option}" in
-\?|-h|--help|--usage) brew help update-reset; exit $? ;;
--debug) HOMEBREW_DEBUG=1 ;;
-\? | -h | --help | --usage) brew help update-reset; exit $? ;;
--debug) HOMEBREW_DEBUG=1 ;;
-*)
[[ "${option}" = *d* ]] && HOMEBREW_DEBUG=1
[[ "${option}" == *d* ]] && HOMEBREW_DEBUG=1
;;
*)
REPOS+=("${option}")

View File

@ -77,7 +77,7 @@ repo_var() {
local repo_var
repo_var="$1"
if [[ "${repo_var}" = "${HOMEBREW_REPOSITORY}" ]]
if [[ "${repo_var}" == "${HOMEBREW_REPOSITORY}" ]]
then
repo_var=""
else
@ -193,16 +193,18 @@ merge_or_rebase() {
trap reset_on_interrupt SIGINT
if [[ "${DIR}" = "${HOMEBREW_REPOSITORY}" && -n "${HOMEBREW_UPDATE_TO_TAG}" ]]
if [[ "${DIR}" == "${HOMEBREW_REPOSITORY}" && -n "${HOMEBREW_UPDATE_TO_TAG}" ]]
then
UPSTREAM_TAG="$(git tag --list |
sort --field-separator=. --key=1,1nr -k 2,2nr -k 3,3nr |
grep --max-count=1 '^[0-9]*\.[0-9]*\.[0-9]*$')"
UPSTREAM_TAG="$(
git tag --list |
sort --field-separator=. --key=1,1nr -k 2,2nr -k 3,3nr |
grep --max-count=1 '^[0-9]*\.[0-9]*\.[0-9]*$'
)"
else
UPSTREAM_TAG=""
fi
if [ -n "${UPSTREAM_TAG}" ]
if [[ -n "${UPSTREAM_TAG}" ]]
then
REMOTE_REF="refs/tags/${UPSTREAM_TAG}"
UPSTREAM_BRANCH="stable"
@ -288,8 +290,8 @@ EOS
if [[ -n "${HOMEBREW_NO_UPDATE_CLEANUP}" ]]
then
if [[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" &&
! "${INITIAL_BRANCH}" =~ ^v[0-9]+\.[0-9]+\.[0-9]|stable$ ]]
if [[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]] &&
[[ ! "${INITIAL_BRANCH}" =~ ^v[0-9]+\.[0-9]+\.[0-9]|stable$ ]]
then
git checkout "${INITIAL_BRANCH}" "${QUIET_ARGS[@]}"
fi
@ -310,7 +312,7 @@ homebrew-update() {
for option in "$@"
do
case "${option}" in
-\?|-h|--help|--usage) brew help update; exit $? ;;
-\? | -h | --help | --usage) brew help update; exit $? ;;
--verbose) HOMEBREW_VERBOSE=1 ;;
--debug) HOMEBREW_DEBUG=1 ;;
--quiet) HOMEBREW_QUIET=1 ;;
@ -320,10 +322,10 @@ homebrew-update() {
--preinstall) export HOMEBREW_UPDATE_PREINSTALL=1 ;;
--*) ;;
-*)
[[ "${option}" = *v* ]] && HOMEBREW_VERBOSE=1
[[ "${option}" = *q* ]] && HOMEBREW_QUIET=1
[[ "${option}" = *d* ]] && HOMEBREW_DEBUG=1
[[ "${option}" = *f* ]] && HOMEBREW_UPDATE_FORCE=1
[[ "${option}" == *v* ]] && HOMEBREW_VERBOSE=1
[[ "${option}" == *q* ]] && HOMEBREW_QUIET=1
[[ "${option}" == *d* ]] && HOMEBREW_DEBUG=1
[[ "${option}" == *f* ]] && HOMEBREW_UPDATE_FORCE=1
;;
*)
odie <<EOS
@ -371,8 +373,7 @@ EOS
fi
# we may want to use a Homebrew curl
if [[ -n "${HOMEBREW_FORCE_BREWED_CURL}" &&
! -x "${HOMEBREW_PREFIX}/opt/curl/bin/curl" ]]
if [[ -n "${HOMEBREW_FORCE_BREWED_CURL}" && ! -x "${HOMEBREW_PREFIX}/opt/curl/bin/curl" ]]
then
# we cannot install a Homebrew cURL if homebrew/core is unavailable.
if [[ ! -d "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]] || ! brew install curl
@ -382,8 +383,7 @@ EOS
fi
if ! git --version &>/dev/null ||
[[ -n "${HOMEBREW_FORCE_BREWED_GIT}" &&
! -x "${HOMEBREW_PREFIX}/opt/git/bin/git" ]]
[[ -n "${HOMEBREW_FORCE_BREWED_GIT}" && ! -x "${HOMEBREW_PREFIX}/opt/git/bin/git" ]]
then
# we cannot install a Homebrew Git if homebrew/core is unavailable.
if [[ ! -d "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]] || ! brew install git
@ -394,7 +394,7 @@ EOS
[[ -f "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/.git/shallow" ]] && HOMEBREW_CORE_SHALLOW=1
[[ -f "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask/.git/shallow" ]] && HOMEBREW_CASK_SHALLOW=1
if [[ -n ${HOMEBREW_CORE_SHALLOW} && -n ${HOMEBREW_CASK_SHALLOW} ]]
if [[ -n "${HOMEBREW_CORE_SHALLOW}" && -n "${HOMEBREW_CASK_SHALLOW}" ]]
then
SHALLOW_COMMAND_PHRASE="These commands"
SHALLOW_REPO_PHRASE="repositories"
@ -403,7 +403,7 @@ EOS
SHALLOW_REPO_PHRASE="repository"
fi
if [[ -n ${HOMEBREW_CORE_SHALLOW} || -n ${HOMEBREW_CASK_SHALLOW} ]]
if [[ -n "${HOMEBREW_CORE_SHALLOW}" || -n "${HOMEBREW_CASK_SHALLOW}" ]]
then
odie <<EOS
${HOMEBREW_CORE_SHALLOW:+
@ -480,9 +480,8 @@ EOS
safe_cd "${HOMEBREW_REPOSITORY}"
# if an older system had a newer curl installed, change each repo's remote URL from GIT to HTTPS
if [[ -n "${HOMEBREW_SYSTEM_CURL_TOO_OLD}" &&
-x "${HOMEBREW_PREFIX}/opt/curl/bin/curl" &&
"$(git config remote.origin.url)" =~ ^git:// ]]
if [[ -n "${HOMEBREW_SYSTEM_CURL_TOO_OLD}" && -x "${HOMEBREW_PREFIX}/opt/curl/bin/curl" ]] &&
[[ "$(git config remote.origin.url)" =~ ^git:// ]]
then
git config remote.origin.url "${HOMEBREW_BREW_GIT_REMOTE}"
git config -f "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/.git/config" remote.origin.url "${HOMEBREW_CORE_GIT_REMOTE}"
@ -498,8 +497,9 @@ EOS
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
do
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] && [[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]] &&
[[ "${DIR}" = "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]]
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
[[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]] &&
[[ "${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]]
then
continue
fi
@ -518,15 +518,15 @@ EOS
declare PREFETCH_REVISION"${TAP_VAR}"="$(git rev-parse -q --verify refs/remotes/origin/"${UPSTREAM_BRANCH_DIR}")"
# Force a full update if we don't have any tags.
if [[ "${DIR}" = "${HOMEBREW_REPOSITORY}" && -z "$(git tag --list)" ]]
if [[ "${DIR}" == "${HOMEBREW_REPOSITORY}" && -z "$(git tag --list)" ]]
then
HOMEBREW_UPDATE_FORCE=1
fi
if [[ -z "${HOMEBREW_UPDATE_FORCE}" ]]
then
[[ -n "${SKIP_FETCH_BREW_REPOSITORY}" && "${DIR}" = "${HOMEBREW_REPOSITORY}" ]] && continue
[[ -n "${SKIP_FETCH_CORE_REPOSITORY}" && "${DIR}" = "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]] && continue
[[ -n "${SKIP_FETCH_BREW_REPOSITORY}" && "${DIR}" == "${HOMEBREW_REPOSITORY}" ]] && continue
[[ -n "${SKIP_FETCH_CORE_REPOSITORY}" && "${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]] && continue
fi
# The upstream repository's default branch may not be master;
@ -538,12 +538,12 @@ EOS
# HOMEBREW_UPDATE_FORCE and HOMEBREW_UPDATE_PREINSTALL aren't modified here so ignore subshell warning.
# shellcheck disable=SC2030
if [[ "${UPSTREAM_REPOSITORY_URL}" = "https://github.com/"* ]]
if [[ "${UPSTREAM_REPOSITORY_URL}" == "https://github.com/"* ]]
then
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_URL#https://github.com/}"
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY%.git}"
if [[ "${DIR}" = "${HOMEBREW_REPOSITORY}" && -n "${HOMEBREW_UPDATE_TO_TAG}" ]]
if [[ "${DIR}" == "${HOMEBREW_REPOSITORY}" && -n "${HOMEBREW_UPDATE_TO_TAG}" ]]
then
# Only try to `git fetch` when the upstream tags have changed
# (so the API does not return 304: unmodified).
@ -560,19 +560,21 @@ EOS
# HOMEBREW_CURL is set by brew.sh (and isn't mispelt here)
# shellcheck disable=SC2153
UPSTREAM_SHA_HTTP_CODE="$("${HOMEBREW_CURL}" \
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
--silent --max-time 3 \
--location --no-remote-time --output /dev/null --write-out "%{http_code}" \
--dump-header "${DIR}/.git/GITHUB_HEADERS" \
--user-agent "${HOMEBREW_USER_AGENT_CURL}" \
--header "Accept: ${GITHUB_API_ACCEPT}" \
--header "If-None-Match: \"${GITHUB_API_ETAG}\"" \
"https://api.github.com/repos/${UPSTREAM_REPOSITORY}/${GITHUB_API_ENDPOINT}")"
UPSTREAM_SHA_HTTP_CODE="$(
"${HOMEBREW_CURL}" \
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
--silent --max-time 3 \
--location --no-remote-time --output /dev/null --write-out "%{http_code}" \
--dump-header "${DIR}/.git/GITHUB_HEADERS" \
--user-agent "${HOMEBREW_USER_AGENT_CURL}" \
--header "Accept: ${GITHUB_API_ACCEPT}" \
--header "If-None-Match: \"${GITHUB_API_ETAG}\"" \
"https://api.github.com/repos/${UPSTREAM_REPOSITORY}/${GITHUB_API_ENDPOINT}"
)"
# Touch FETCH_HEAD to confirm we've checked for an update.
[[ -f "${DIR}/.git/FETCH_HEAD" ]] && touch "${DIR}/.git/FETCH_HEAD"
[[ -z "${HOMEBREW_UPDATE_FORCE}" ]] && [[ "${UPSTREAM_SHA_HTTP_CODE}" = "304" ]] && exit
[[ -z "${HOMEBREW_UPDATE_FORCE}" ]] && [[ "${UPSTREAM_SHA_HTTP_CODE}" == "304" ]] && exit
elif [[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]]
then
FORCE_AUTO_UPDATE="$(git config homebrew.forceautoupdate 2>/dev/null || echo "false")"
@ -583,7 +585,6 @@ EOS
fi
fi
# HOMEBREW_VERBOSE isn't modified here so ignore subshell warning.
# shellcheck disable=SC2030
if [[ -n "${HOMEBREW_VERBOSE}" ]]
@ -606,7 +607,7 @@ EOS
# Reprint fetch errors to stderr
[[ -f "${tmp_failure_file}" ]] && cat "${tmp_failure_file}" 1>&2
if [[ "${UPSTREAM_SHA_HTTP_CODE}" = "404" ]]
if [[ "${UPSTREAM_SHA_HTTP_CODE}" == "404" ]]
then
TAP="${DIR#${HOMEBREW_LIBRARY}/Taps/}"
echo "${TAP} does not exist! Run \`brew untap ${TAP}\` to remove it." >>"${update_failed_file}"
@ -614,7 +615,7 @@ EOS
echo "Fetching ${DIR} failed!" >>"${update_failed_file}"
if [[ -f "${tmp_failure_file}" ]] &&
[[ "$(<"${tmp_failure_file}")" = "fatal: couldn't find remote ref refs/heads/${UPSTREAM_BRANCH_DIR}" ]]
[[ "$(cat "${tmp_failure_file}")" == "fatal: couldn't find remote ref refs/heads/${UPSTREAM_BRANCH_DIR}" ]]
then
echo "${DIR}" >>"${missing_remote_ref_dirs_file}"
fi
@ -638,7 +639,7 @@ EOS
if [[ -f "${missing_remote_ref_dirs_file}" ]]
then
HOMEBREW_MISSING_REMOTE_REF_DIRS="$(<"${missing_remote_ref_dirs_file}")"
HOMEBREW_MISSING_REMOTE_REF_DIRS="$(cat "${missing_remote_ref_dirs_file}")"
rm -f "${missing_remote_ref_dirs_file}"
export HOMEBREW_MISSING_REMOTE_REF_DIRS
fi
@ -647,9 +648,10 @@ EOS
do
# HOMEBREW_UPDATE_PREINSTALL wasn't modified in subshell.
# shellcheck disable=SC2031
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] && [[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]] &&
[[ "${DIR}" = "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ||
"${DIR}" = "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" ]]
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
[[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]] &&
[[ "${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" || \
"${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" ]]
then
continue
fi
@ -672,8 +674,8 @@ EOS
then
simulate_from_current_branch "${DIR}" "${TAP_VAR}" "${UPSTREAM_BRANCH}" "${CURRENT_REVISION}"
elif [[ -z "${HOMEBREW_UPDATE_FORCE}" ]] &&
[[ "${PREFETCH_REVISION}" = "${POSTFETCH_REVISION}" ]] &&
[[ "${CURRENT_REVISION}" = "${POSTFETCH_REVISION}" ]]
[[ "${PREFETCH_REVISION}" == "${POSTFETCH_REVISION}" ]] &&
[[ "${CURRENT_REVISION}" == "${POSTFETCH_REVISION}" ]]
then
export HOMEBREW_UPDATE_BEFORE"${TAP_VAR}"="${CURRENT_REVISION}"
export HOMEBREW_UPDATE_AFTER"${TAP_VAR}"="${CURRENT_REVISION}"
@ -687,18 +689,17 @@ EOS
# HOMEBREW_UPDATE_PREINSTALL wasn't modified in subshell.
# shellcheck disable=SC2031
if [[ -n "${HOMEBREW_UPDATED}" ||
-n "${HOMEBREW_UPDATE_FAILED}" ||
-n "${HOMEBREW_MISSING_REMOTE_REF_DIRS}" ||
-n "${HOMEBREW_UPDATE_FORCE}" ||
-d "${HOMEBREW_LIBRARY}/LinkedKegs" ||
! -f "${HOMEBREW_CACHE}/all_commands_list.txt" ||
(-n "${HOMEBREW_DEVELOPER}" && -z "${HOMEBREW_UPDATE_PREINSTALL}") ]]
if [[ -n "${HOMEBREW_UPDATED}" ]] ||
[[ -n "${HOMEBREW_UPDATE_FAILED}" ]] ||
[[ -n "${HOMEBREW_MISSING_REMOTE_REF_DIRS}" ]] ||
[[ -n "${HOMEBREW_UPDATE_FORCE}" ]] ||
[[ -d "${HOMEBREW_LIBRARY}/LinkedKegs" ]] ||
[[ ! -f "${HOMEBREW_CACHE}/all_commands_list.txt" ]] ||
[[ -n "${HOMEBREW_DEVELOPER}" && -z "${HOMEBREW_UPDATE_PREINSTALL}" ]]
then
brew update-report "$@"
return $?
elif [[ -z "${HOMEBREW_UPDATE_PREINSTALL}" &&
-z "${HOMEBREW_QUIET}" ]]
elif [[ -z "${HOMEBREW_UPDATE_PREINSTALL}" && -z "${HOMEBREW_QUIET}" ]]
then
echo "Already up-to-date."
fi

View File

@ -14,7 +14,7 @@ VENDOR_DIR="${HOMEBREW_LIBRARY}/Homebrew/vendor"
# Built from https://github.com/Homebrew/homebrew-portable-ruby.
if [[ -n "${HOMEBREW_MACOS}" ]]
then
if [[ "${HOMEBREW_PROCESSOR}" = "Intel" ]]
if [[ "${HOMEBREW_PROCESSOR}" == "Intel" ]]
then
ruby_FILENAME="portable-ruby-2.6.3_2.yosemite.bottle.tar.gz"
ruby_SHA="b065e5e3783954f3e65d8d3a6377ca51649bfcfa21b356b0dd70490f74c6bd86"
@ -26,7 +26,7 @@ then
ruby_FILENAME="portable-ruby-2.6.3_2.x86_64_linux.bottle.tar.gz"
ruby_SHA="97e639a64dcec285392b53ad804b5334c324f1d2a8bdc2b5087b8bf8051e332f"
;;
*)
*) ;;
esac
fi
@ -43,13 +43,15 @@ then
then
ruby_URLs+=("${HOMEBREW_BOTTLE_DOMAIN}/bottles-portable-ruby/${ruby_FILENAME}")
fi
ruby_URLs+=("https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}"
"https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.3_2/${ruby_FILENAME}")
ruby_URLs+=(
"https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}"
"https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.3_2/${ruby_FILENAME}"
)
ruby_URL="${ruby_URLs[0]}"
fi
check_linux_glibc_version() {
if [[ -z ${HOMEBREW_LINUX} || -z ${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION} ]]
if [[ -z "${HOMEBREW_LINUX}" || -z "${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION}" ]]
then
return 0
fi
@ -58,15 +60,15 @@ check_linux_glibc_version() {
local glibc_version_major
local glibc_version_minor
local minimum_required_major=${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION%.*}
local minimum_required_minor=${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION#*.}
local minimum_required_major="${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION%.*}"
local minimum_required_minor="${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION#*.}"
if [[ $(/usr/bin/ldd --version) =~ \ [0-9]\.[0-9]+ ]]
if [[ "$(/usr/bin/ldd --version)" =~ \ [0-9]\.[0-9]+ ]]
then
glibc_version=${BASH_REMATCH[0]// /}
glibc_version_major=${glibc_version%.*}
glibc_version_minor=${glibc_version#*.}
if (( glibc_version_major < minimum_required_major || glibc_version_minor < minimum_required_minor ))
glibc_version="${BASH_REMATCH[0]// /}"
glibc_version_major="${glibc_version%.*}"
glibc_version_minor="${glibc_version#*.}"
if ((glibc_version_major < minimum_required_major || glibc_version_minor < minimum_required_minor))
then
odie "Vendored tools require system Glibc ${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION} or later (yours is ${glibc_version})."
fi
@ -77,7 +79,8 @@ check_linux_glibc_version() {
# Execute the specified command, and suppress stderr unless HOMEBREW_STDERR is set.
quiet_stderr() {
if [[ -z "${HOMEBREW_STDERR}" ]]; then
if [[ -z "${HOMEBREW_STDERR}" ]]
then
command "$@" 2>/dev/null
else
command "$@"
@ -180,13 +183,14 @@ EOS
sha="$(sha256sum "${CACHED_LOCATION}" | cut -d' ' -f1)"
elif [[ -x "$(type -P ruby)" ]]
then
sha="$(ruby <<EOSCRIPT
require 'digest/sha2'
digest = Digest::SHA256.new
File.open('${CACHED_LOCATION}', 'rb') { |f| digest.update(f.read) }
puts digest.hexdigest
sha="$(
ruby <<EOSCRIPT
require 'digest/sha2'
digest = Digest::SHA256.new
File.open('${CACHED_LOCATION}', 'rb') { |f| digest.update(f.read) }
puts digest.hexdigest
EOSCRIPT
)"
)"
else
odie "Cannot verify checksum ('shasum' or 'sha256sum' not found)!"
fi
@ -261,9 +265,9 @@ homebrew-vendor-install() {
--debug) HOMEBREW_DEBUG=1 ;;
--*) ;;
-*)
[[ "${option}" = *v* ]] && HOMEBREW_VERBOSE=1
[[ "${option}" = *q* ]] && HOMEBREW_QUIET=1
[[ "${option}" = *d* ]] && HOMEBREW_DEBUG=1
[[ "${option}" == *v* ]] && HOMEBREW_VERBOSE=1
[[ "${option}" == *q* ]] && HOMEBREW_QUIET=1
[[ "${option}" == *d* ]] && HOMEBREW_DEBUG=1
;;
*)
[[ -n "${VENDOR_NAME}" ]] && odie "This command does not take multiple vendor targets!"
@ -282,7 +286,7 @@ homebrew-vendor-install() {
VENDOR_FILENAME="${!filename_var}"
VENDOR_SHA="${!sha_var}"
VENDOR_URL="${!url_var}"
VENDOR_VERSION="$(<"${VENDOR_DIR}/portable-${VENDOR_NAME}-version")"
VENDOR_VERSION="$(cat "${VENDOR_DIR}/portable-${VENDOR_NAME}-version")"
if [[ -z "${VENDOR_URL}" || -z "${VENDOR_SHA}" ]]
then
@ -292,7 +296,7 @@ homebrew-vendor-install() {
# Expand the name to an array of variables
# The array name must be "${VENDOR_NAME}_URLs"! Otherwise substitution errors will occur!
# shellcheck disable=SC2086
read -r -a VENDOR_URLs <<< "$(eval "echo "\$\{${url_var}s[@]\}"")"
read -r -a VENDOR_URLs <<<"$(eval "echo "\$\{${url_var}s[@]\}"")"
CACHED_LOCATION="${HOMEBREW_CACHE}/${VENDOR_FILENAME}"

View File

@ -14,7 +14,8 @@ homebrew-rubocop() {
GEM_VERSION="$("${HOMEBREW_RUBY_PATH}" "${RUBY_DISABLE_OPTIONS}" -rrbconfig -e 'puts RbConfig::CONFIG["ruby_version"]')"
GEM_HOME="${HOMEBREW_LIBRARY}/Homebrew/vendor/bundle/ruby/${GEM_VERSION}"
if ! [[ -f "${GEM_HOME}/bin/rubocop" ]]; then
if ! [[ -f "${GEM_HOME}/bin/rubocop" ]]
then
"${HOMEBREW_BREW_FILE}" install-bundler-gems
fi

View File

@ -1,13 +1,14 @@
homebrew-items() {
local items
local sed_extended_regex_flag
local find_filter=$1
local sed_filter=$2
local grep_filter=$3
local find_filter="$1"
local sed_filter="$2"
local grep_filter="$3"
# HOMEBREW_MACOS is set by brew.sh
# shellcheck disable=SC2154
if [[ -n "${HOMEBREW_MACOS}" ]]; then
if [[ -n "${HOMEBREW_MACOS}" ]]
then
sed_extended_regex_flag="-E"
else
sed_extended_regex_flag="-r"
@ -15,7 +16,7 @@ homebrew-items() {
# HOMEBREW_REPOSITORY is set by brew.sh
# shellcheck disable=SC2154
items="$( \
items="$(
find "${HOMEBREW_REPOSITORY}/Library/Taps" \
-type d \( \
-name "${find_filter}" -o \
@ -25,15 +26,15 @@ homebrew-items() {
-name spec -o \
-name vendor \
\) \
-prune -false -o -name '*\.rb' | \
sed "${sed_extended_regex_flag}" \
-e 's/\.rb//g' \
-e 's_.*/Taps/(.*)/(home|linux)brew-_\1/_' \
-e "${sed_filter}" \
-prune -false -o -name '*\.rb' |
sed "${sed_extended_regex_flag}" \
-e 's/\.rb//g' \
-e 's_.*/Taps/(.*)/(home|linux)brew-_\1/_' \
-e "${sed_filter}"
)"
local shortnames
shortnames="$(echo "${items}" | cut -d "/" -f 3)"
echo -e "${items}\n${shortnames}" | \
grep -v "${grep_filter}" | \
echo -e "${items}\n${shortnames}" |
grep -v "${grep_filter}" |
sort -uf
}

View File

@ -5,20 +5,27 @@
# HOMEBREW_PREFIX and HOMEBREW_REPOSITORY are set by brew.sh
# shellcheck disable=SC2154
homebrew-prefix() {
while [[ "$#" -gt 0 ]]; do
case $1 in
# check we actually have --prefix and not e.g. --prefixsomething
--prefix) local prefix="1"; shift ;;
# reject all other flags
-*) return 1 ;;
*) [ -n "${formula}" ] && return 1; local formula="$1"; shift ;;
esac
while [[ "$#" -gt 0 ]]
do
case "$1" in
# check we actually have --prefix and not e.g. --prefixsomething
--prefix)
local prefix="1"; shift
;;
# reject all other flags
-*) return 1 ;;
*)
[[ -n "${formula}" ]] && return 1
local formula="$1"; shift
;;
esac
done
[ -z "${prefix}" ] && return 1
[ -z "${formula}" ] && echo "${HOMEBREW_PREFIX}" && return 0
[[ -z "${prefix}" ]] && return 1
[[ -z "${formula}" ]] && echo "${HOMEBREW_PREFIX}" && return 0
local formula_path
if [ -f "${HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-core/Formula/${formula}.rb" ]; then
if [[ -f "${HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-core/Formula/${formula}.rb" ]]
then
formula_path="${HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-core/Formula/${formula}.rb"
else
formula_path="$(
@ -26,7 +33,7 @@ homebrew-prefix() {
echo "${HOMEBREW_REPOSITORY}/Library/Taps"/*/*/{Formula/,HomebrewFormula/,}"${formula}.rb"
)"
fi
[ -z "${formula_path}" ] && return 1
[[ -z "${formula_path}" ]] && return 1
echo "${HOMEBREW_PREFIX}/opt/${formula}"
return 0

View File

@ -4,13 +4,19 @@
# HOMEBREW_LIBRARY is set by bin/brew
# shellcheck disable=SC2154,SC2250
pathremove() {
local IFS=':' NEWPATH="" DIR="" PATHVARIABLE=${2:-PATH}
for DIR in ${!PATHVARIABLE} ; do
if [ "${DIR}" != "$1" ] ; then
NEWPATH=${NEWPATH:+$NEWPATH:}${DIR}
fi
done
export "${PATHVARIABLE}"="${NEWPATH}"
local IFS=':'
local NEWPATH=""
local DIR=""
local PATHVARIABLE="${2:-PATH}"
for DIR in ${!PATHVARIABLE}
do
if [[ "${DIR}" != "$1" ]]
then
NEWPATH="${NEWPATH:+$NEWPATH:}${DIR}"
fi
done
export "${PATHVARIABLE}"="${NEWPATH}"
}
SAVED_PATH="${PATH}"

View File

@ -4,7 +4,8 @@
# shellcheck disable=SC2154
pkg_config="${HOMEBREW_OPT}/pkg-config/bin/pkg-config"
if [ -z "${HOMEBREW_SDKROOT}" ]; then
if [[ -z "${HOMEBREW_SDKROOT}" ]]
then
exec "${pkg_config}" "$@"
fi

View File

@ -9,8 +9,9 @@ source "${HOMEBREW_LIBRARY}/Homebrew/shims/utils.sh"
try_exec_non_system "${SHIM_FILE}" "$@"
if [[ -z "${SDKROOT}" && -n "${HOMEBREW_SDKROOT}" ]]; then
export SDKROOT=${HOMEBREW_SDKROOT}
if [[ -z "${SDKROOT}" && -n "${HOMEBREW_SDKROOT}" ]]
then
export SDKROOT="${HOMEBREW_SDKROOT}"
fi
safe_exec "/usr/bin/${SHIM_FILE}" "$@"

View File

@ -7,8 +7,9 @@
# shellcheck disable=SC2154
source "${HOMEBREW_LIBRARY}/Homebrew/shims/utils.sh"
if [[ -z "${SDKROOT}" && -n "${HOMEBREW_SDKROOT}" ]]; then
export SDKROOT=${HOMEBREW_SDKROOT}
if [[ -z "${SDKROOT}" && -n "${HOMEBREW_SDKROOT}" ]]
then
export SDKROOT="${HOMEBREW_SDKROOT}"
fi
try_exec_non_system "swift" "$@"

View File

@ -7,18 +7,21 @@
# These could be used in conjunction with `--sdk` which ignores SDKROOT.
# HOMEBREW_DEVELOPER_DIR, HOMEBREW_SDKROOT and HOMEBREW_PREFER_CLT_PROXIES are set by extend/ENV/super.rb
# shellcheck disable=SC2154
if [[ "$*" =~ (^| )-?-show-sdk-(path|version|build) && -n "${HOMEBREW_DEVELOPER_DIR}" ]]; then
export DEVELOPER_DIR=${HOMEBREW_DEVELOPER_DIR}
if [[ "$*" =~ (^| )-?-show-sdk-(path|version|build) && -n "${HOMEBREW_DEVELOPER_DIR}" ]]
then
export DEVELOPER_DIR="${HOMEBREW_DEVELOPER_DIR}"
else
# Some build tools set DEVELOPER_DIR, so discard it
unset DEVELOPER_DIR
fi
if [[ -z "${SDKROOT}" && -n "${HOMEBREW_SDKROOT}" ]]; then
export SDKROOT=${HOMEBREW_SDKROOT}
if [[ -z "${SDKROOT}" && -n "${HOMEBREW_SDKROOT}" ]]
then
export SDKROOT="${HOMEBREW_SDKROOT}"
fi
if [ $# -eq 0 ]; then
if [[ $# -eq 0 ]]
then
exec /usr/bin/xcrun "$@"
fi
@ -27,38 +30,45 @@ case "$1" in
-*) exec /usr/bin/xcrun "$@" ;;
esac
arg0=$1
arg0="$1"
shift
exe="/usr/bin/${arg0}"
if [[ -x "${exe}" ]]; then
if [[ -n "${HOMEBREW_PREFER_CLT_PROXIES}" ]]; then
if [[ -x "${exe}" ]]
then
if [[ -n "${HOMEBREW_PREFER_CLT_PROXIES}" ]]
then
exec "${exe}" "$@"
elif [[ -z "${HOMEBREW_SDKROOT}" || ! -d "${HOMEBREW_SDKROOT}" ]]; then
elif [[ -z "${HOMEBREW_SDKROOT}" || ! -d "${HOMEBREW_SDKROOT}" ]]
then
exec "${exe}" "$@"
fi
fi
SUPERBIN=$(cd "${0%/*}" && pwd -P)
SUPERBIN="$(cd "${0%/*}" && pwd -P)"
exe=$(/usr/bin/xcrun --find "${arg0}" 2>/dev/null)
if [[ -x "${exe}" && "${exe%/*}" != "${SUPERBIN}" ]]; then
exe="$(/usr/bin/xcrun --find "${arg0}" 2>/dev/null)"
if [[ -x "${exe}" && "${exe%/*}" != "${SUPERBIN}" ]]
then
exec "${exe}" "$@"
fi
old_IFS=${IFS}
IFS=:
for path in ${PATH}; do
if [ "${path}" = "${SUPERBIN}" ]; then
old_IFS="${IFS}"
IFS=':'
for path in ${PATH}
do
if [[ "${path}" == "${SUPERBIN}" ]]
then
continue
fi
exe="${path}/${arg0}"
if [ -x "${exe}" ]; then
if [[ -x "${exe}" ]]
then
exec "${exe}" "$@"
fi
done
IFS=${old_IFS}
IFS="${old_IFS}"
echo >&2 "
Failed to execute ${arg0} ${*}

View File

@ -7,9 +7,9 @@
# SHIM_FILE is set by shims/utils.sh
# HOMEBREW_GIT is set by brew.sh
# HOMEBREW_SVN is from the user environment.
# HOMEBREW_PREFIX is set extend/ENV/super.rb
# HOMEBREW_PREFIX is set by extend/ENV/super.rb
# shellcheck disable=SC2154
if [ -z "${HOMEBREW_LIBRARY}" ]
if [[ -z "${HOMEBREW_LIBRARY}" ]]
then
echo "${0##*/}: This shim is internal and must be run via brew." >&2
exit 1

View File

@ -1,11 +1,11 @@
#!/bin/sh
# Make sure this shim uses the same Ruby interpreter that is used by Homebrew.
if [ -z "$HOMEBREW_RUBY_PATH" ]
if [[ -z "${HOMEBREW_RUBY_PATH}" ]]
then
echo "${0##*/}: The build tool has reset ENV; --env=std required." >&2
exit 1
fi
exec "$HOMEBREW_RUBY_PATH" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -x "$0" "$@"
exec "${HOMEBREW_RUBY_PATH}" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -x "$0" "$@"
#!/usr/bin/env ruby -W0
require "pathname"

View File

@ -1,7 +1,10 @@
set +o posix
quiet_safe_cd() {
cd "$1" &>/dev/null || { echo "Error: failed to cd to $1" >&2; exit 1; }
cd "$1" &>/dev/null || {
echo "Error: failed to cd to $1" >&2
exit 1
}
}
absdir() {
@ -25,7 +28,7 @@ realpath() {
while [[ -L "${path}" ]]
do
dest="$(readlink "${path}")"
if [[ "${dest}" = "/"* ]]
if [[ "${dest}" == "/"* ]]
then
path="${dest}"
else
@ -54,11 +57,11 @@ safe_exec() {
return
fi
# prevent fork-bombs
if [[ "$(lowercase "${arg0}")" = "${SHIM_FILE}" || "$(realpath "${arg0}")" = "${SHIM_REAL}" ]]
if [[ "$(lowercase "${arg0}")" == "${SHIM_FILE}" || "$(realpath "${arg0}")" == "${SHIM_REAL}" ]]
then
return
fi
if [[ "${HOMEBREW}" = "print-path" ]]
if [[ "${HOMEBREW}" == "print-path" ]]
then
local dir
dir="$(quiet_safe_cd "${arg0%/*}/" && pwd)"
@ -71,25 +74,23 @@ safe_exec() {
}
try_exec_non_system() {
local file="$1"
local file="$1"
shift
IFS=$'\n'
for path in $(type -aP "${file}")
do
if [[ "${path}" != "/usr/bin/${file}" ]]
then
safe_exec "${path}" "$@"
fi
done
unset IFS
local path
while read -r path
do
if [[ "${path}" != "/usr/bin/${file}" ]]
then
safe_exec "${path}" "$@"
fi
done < <(type -aP "${file}")
}
SHIM_FILE="${0##*/}"
SHIM_REAL="$(realpath "$0")"
if [[ "$1" = --homebrew=* ]]
if [[ "$1" == "--homebrew="* ]]
then
HOMEBREW="${1:11}"
shift

View File

@ -10,7 +10,7 @@ migrate-legacy-uuid-file() {
if [[ -f "${legacy_uuid_file}" ]]
then
analytics_uuid="$(<"${legacy_uuid_file}")"
analytics_uuid="$(cat "${legacy_uuid_file}")"
if [[ -n "${analytics_uuid}" ]]
then
git config --file="${HOMEBREW_REPOSITORY}/.git/config" --replace-all homebrew.analyticsuuid "${analytics_uuid}" 2>/dev/null
@ -32,7 +32,7 @@ setup-analytics() {
local message_seen analytics_disabled
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
# Internal variable for brew's use, to differentiate from user-supplied setting
export HOMEBREW_NO_ANALYTICS_THIS_RUN="1"

View File

@ -8,7 +8,7 @@ lock() {
local lock_dir="${HOMEBREW_PREFIX}/var/homebrew/locks"
local lock_file="${lock_dir}/${name}"
[[ -d "${lock_dir}" ]] || mkdir -p "${lock_dir}"
if ! [[ -w "${lock_dir}" ]]
if [[ ! -w "${lock_dir}" ]]
then
odie <<EOS
Can't create ${name} lock in ${lock_dir}!

View File

@ -8,14 +8,14 @@ which_all() {
fi
local executable entries entry retcode=1
IFS=':' read -r -a entries <<< "${PATH}" # `readarray -d ':' -t` seems not applicable on WSL Bash
IFS=':' read -r -a entries <<<"${PATH}" # `readarray -d ':' -t` seems not applicable on WSL Bash
for entry in "${entries[@]}"
do
executable="${entry}/$1"
if [[ -x "${executable}" ]]
then
echo "${executable}"
retcode=0 # present
retcode=0 # present
fi
done
@ -46,7 +46,8 @@ find_ruby() {
local ruby_exec
while read -r ruby_exec
do
if test_ruby "${ruby_exec}"; then
if test_ruby "${ruby_exec}"
then
echo "${ruby_exec}"
break
fi
@ -90,7 +91,7 @@ setup-ruby-path() {
local upgrade_fail
local install_fail
if [[ -n ${HOMEBREW_MACOS} ]]
if [[ -n "${HOMEBREW_MACOS}" ]]
then
upgrade_fail="Failed to upgrade Homebrew Portable Ruby!"
install_fail="Failed to install Homebrew Portable Ruby (and your system version is too old)!"
@ -109,8 +110,8 @@ If there's no Homebrew Portable Ruby available for your processor:
vendor_ruby_root="${vendor_dir}/portable-ruby/current"
vendor_ruby_path="${vendor_ruby_root}/bin/ruby"
vendor_ruby_terminfo="${vendor_ruby_root}/share/terminfo"
vendor_ruby_latest_version=$(<"${vendor_dir}/portable-ruby-version")
vendor_ruby_current_version=$(readlink "${vendor_ruby_root}")
vendor_ruby_latest_version="$(cat "${vendor_dir}/portable-ruby-version")"
vendor_ruby_current_version="$(readlink "${vendor_ruby_root}")"
unset HOMEBREW_RUBY_PATH
@ -123,12 +124,12 @@ If there's no Homebrew Portable Ruby available for your processor:
then
HOMEBREW_RUBY_PATH="${vendor_ruby_path}"
TERMINFO_DIRS="${vendor_ruby_terminfo}"
if [[ ${vendor_ruby_current_version} != "${vendor_ruby_latest_version}" ]]
if [[ "${vendor_ruby_current_version}" != "${vendor_ruby_latest_version}" ]]
then
brew vendor-install ruby || odie "${upgrade_fail}"
fi
else
HOMEBREW_RUBY_PATH=$(find_ruby)
HOMEBREW_RUBY_PATH="$(find_ruby)"
if need_vendored_ruby
then
brew vendor-install ruby || odie "${install_fail}"

View File

@ -114,7 +114,7 @@ then
# Skip if variable value is empty.
[[ -z "${!VAR}" ]] && continue
FILTERED_ENV+=( "${VAR}=${!VAR}" )
FILTERED_ENV+=("${VAR}=${!VAR}")
done
exec /usr/bin/env -i "${FILTERED_ENV[@]}" /bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" "$@"

View File

@ -17,14 +17,14 @@ After running `brew update`, you receive a Git error warning about untracked fil
This is caused by an old bug in in the `update` code that has long since been fixed. However, the nature of the bug requires that you do the following:
```sh
cd $(brew --repository)
cd "$(brew --repository)"
git reset --hard FETCH_HEAD
```
If `brew doctor` still complains about uncommitted modifications, also run this command:
```sh
cd $(brew --repository)/Library
cd "$(brew --repository)/Library"
git clean -fd
```
@ -71,7 +71,7 @@ Please report this bug:
This happens because an old version of the upgrade command is hanging around for some reason. The fix:
```sh
cd $(brew --repository)/Library/Contributions/examples
cd "$(brew --repository)/Library/Contributions/examples"
git clean -n # if this doesn't list anything that you want to keep, then
git clean -f # this will remove untracked files
```

View File

@ -55,7 +55,7 @@ Homebrew doesn't support arbitrary mixing and matching of formula versions, so e
Which is usually: `~/Library/Caches/Homebrew`
## My Mac `.app`s dont find Homebrew utilities!
GUI apps on macOS dont have Homebrew's prefix in their `PATH` by default. If you're on Mountain Lion or later, you can fix this by running `sudo launchctl config user path "$(brew --prefix)/bin:$PATH"` and then rebooting, as documented in `man launchctl`. Note that this sets the launchctl `PATH` for *all users*. For earlier versions of macOS, see [this page](https://developer.apple.com/legacy/library/qa/qa1067/_index.html).
GUI apps on macOS dont have Homebrew's prefix in their `PATH` by default. If you're on Mountain Lion or later, you can fix this by running `sudo launchctl config user path "$(brew --prefix)/bin:${PATH}"` and then rebooting, as documented in `man launchctl`. Note that this sets the launchctl `PATH` for *all users*. For earlier versions of macOS, see [this page](https://developer.apple.com/legacy/library/qa/qa1067/_index.html).
## How do I contribute to Homebrew?
Read our [contribution guidelines](https://github.com/Homebrew/brew/blob/HEAD/CONTRIBUTING.md#contributing-to-homebrew).
@ -84,7 +84,7 @@ We aim to bottle everything.
```sh
brew install hub
brew update
cd $(brew --repository)
cd "$(brew --repository)"
hub pull someone_else
```

View File

@ -361,7 +361,7 @@ Everything is built on Git, so contribution is easy:
```sh
brew update # required in more ways than you think (initialises the brew git repository if you don't already have it)
cd $(brew --repository homebrew/core)
cd "$(brew --repository homebrew/core)"
# Create a new git branch for your formula so your pull request is easy to
# modify if any changes come up during review.
git checkout -b <some-descriptive-name> origin/master

View File

@ -118,7 +118,7 @@ Then put the appropriate incantation in your shells startup, e.g. for
[`local::lib`](https://metacpan.org/pod/local::lib) docs.
```sh
eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
```
Now (after you restart your shell) `cpan` or `perl -MCPAN -eshell` etc.

View File

@ -77,7 +77,7 @@ For brewed Python, modules installed with `pip3` or `python3 setup.py install` w
The system Python may not know which compiler flags to set in order to build bindings for software installed in Homebrew so you may need to run:
```sh
CFLAGS=-I$(brew --prefix)/include LDFLAGS=-L$(brew --prefix)/lib pip install <package>
CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib" pip install <package>
```
## Virtualenv

View File

@ -44,9 +44,9 @@ variable, or let `hub fork` add a remote for you.
```bash
brew install hub
cd $(brew --repository homebrew/core)
cd "$(brew --repository homebrew/core)"
git remote add homebrew https://github.com/Homebrew/homebrew-core.git
hub fork --remote-name=$HOMEBREW_GITHUB_USER
hub fork --remote-name="${HOMEBREW_GITHUB_USER}"
```
Now, let's make sure that our local branch `master` is clean and that
@ -56,7 +56,7 @@ your fork is up-to-date with Homebrew/linuxbrew-core:
git checkout master
git fetch origin master
git reset --hard origin/master
git push --force $HOMEBREW_GITHUB_USER master
git push --force "${HOMEBREW_GITHUB_USER}" master
```
Strictly speaking, there is no need for `git reset --hard
@ -220,8 +220,9 @@ manually, tap `Homebrew/homebrew-linux-dev` and run the following
command where the merge commit is `HEAD`:
```sh
for formula in $(brew find-formulae-to-bottle); do
brew request-bottle $formula
for formula in $(brew find-formulae-to-bottle)
do
brew request-bottle "${formula}"
done
```

View File

@ -31,10 +31,10 @@ The prefix `/home/linuxbrew/.linuxbrew` was chosen so that users without admin a
Follow the *Next steps* instructions to add Homebrew to your `PATH` and to your bash shell profile script, either `~/.profile` on Debian/Ubuntu or `~/.bash_profile` on CentOS/Fedora/Red Hat.
```sh
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.bash_profile
echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.profile
```
You're done! Try installing a package:
@ -86,7 +86,7 @@ Extract or `git clone` Homebrew wherever you want. Use `/home/linuxbrew/.linuxbr
git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew
mkdir ~/.linuxbrew/bin
ln -s ~/.linuxbrew/Homebrew/bin/brew ~/.linuxbrew/bin
eval $(~/.linuxbrew/bin/brew shellenv)
eval "$(~/.linuxbrew/bin/brew shellenv)"
```
## Homebrew on Linux Community

View File

@ -15,7 +15,7 @@ Depending on the change you want to make, you need to send the pull request to t
* This creates a personal remote repository that you can push to. This is needed because only Homebrew maintainers have push access to the main repositories.
2. Change to the directory containing your Homebrew installation:
```sh
cd $(brew --repository)
cd "$(brew --repository)"
```
3. Add your pushable forked repository as a new remote:
```sh
@ -29,7 +29,7 @@ Depending on the change you want to make, you need to send the pull request to t
* This creates a personal remote repository that you can push to. This is needed because only Homebrew maintainers have push access to the main repositories.
2. Change to the directory containing Homebrew formulae:
```sh
cd $(brew --repository homebrew/core)
cd "$(brew --repository homebrew/core)"
```
3. Add your pushable forked repository as a new remote:
```sh

View File

@ -27,13 +27,13 @@ Useful, reliable alternatives exist should you wish to use `keg_only` tools outs
You can set flags to give configure scripts or Makefiles a nudge in the right direction. An example of flag setting:
```sh
./configure --prefix=/Users/Dave/Downloads CFLAGS=-I$(brew --prefix)/opt/openssl/include LDFLAGS=-L$(brew --prefix)/opt/openssl/lib
./configure --prefix=/Users/Dave/Downloads CFLAGS="-I$(brew --prefix)/opt/openssl/include" LDFLAGS="-L$(brew --prefix)/opt/openssl/lib"
```
An example using `pip`:
```sh
CFLAGS=-I$(brew --prefix)/opt/icu4c/include LDFLAGS=-L$(brew --prefix)/opt/icu4c/lib pip install pyicu
CFLAGS="-I$(brew --prefix)/opt/icu4c/include" LDFLAGS="-L$(brew --prefix)/opt/icu4c/lib" pip install pyicu
```
### `PATH` modification
@ -41,7 +41,7 @@ CFLAGS=-I$(brew --prefix)/opt/icu4c/include LDFLAGS=-L$(brew --prefix)/opt/icu4c
You can temporarily prepend your `PATH` with the tools `bin` directory, such as:
```sh
export PATH=$(brew --prefix)/opt/openssl/bin:$PATH
export PATH="$(brew --prefix)/opt/openssl/bin:${PATH}"
```
This will prepend that folder to your `PATH`, ensuring any build script that searches the `PATH` will find it first.
@ -55,7 +55,7 @@ If the tool you are attempting to build is [pkg-config](https://en.wikipedia.org
An example of this is:
```sh
export PKG_CONFIG_PATH=$(brew --prefix)/opt/openssl/lib/pkgconfig
export PKG_CONFIG_PATH="$(brew --prefix)/opt/openssl/lib/pkgconfig"
```
If youre curious about the `PKG_CONFIG_PATH` variable `man pkg-config` goes into more detail.

View File

@ -572,7 +572,7 @@ Print export statements. When run in a shell, this installation of Homebrew will
The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
The variable `HOMEBREW_SHELLENV_PREFIX` will be exported to avoid adding duplicate entries to the environment variables.
Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval $(brew shellenv)`
Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval "$(brew shellenv)"`
### `tap` [*`options`*] [*`user`*`/`*`repo`*] [*`URL`*]

View File

@ -13,13 +13,16 @@ Shell completions for external Homebrew commands are not automatically installed
To make Homebrew's completions available in `bash`, you must source the definitions as part of your shell's startup. Add the following to your `~/.bash_profile` (or, if it doesn't exist, `~/.profile`):
```sh
if type brew &>/dev/null; then
if type brew &>/dev/null
then
HOMEBREW_PREFIX="$(brew --prefix)"
if [[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]; then
if [[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]
then
source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
else
for COMPLETION in "${HOMEBREW_PREFIX}/etc/bash_completion.d/"*; do
[[ -r "$COMPLETION" ]] && source "$COMPLETION"
for COMPLETION in "${HOMEBREW_PREFIX}/etc/bash_completion.d/"*
do
[[ -r "${COMPLETION}" ]] && source "${COMPLETION}"
done
fi
fi
@ -35,8 +38,9 @@ If you are using the `bash` formula as your shell (i.e. `bash` >= v4) you should
To make Homebrew's completions available in `zsh`, you must get the Homebrew-managed zsh site-functions on your `FPATH` before initialising `zsh`'s completion facility. Add the following to your `~/.zshrc` file:
```sh
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
if type brew &>/dev/null
then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
autoload -Uz compinit
compinit
@ -46,7 +50,7 @@ fi
This must be done before `compinit` is called. Note that if you are using Oh My Zsh, it will call `compinit` for you, so this must be done before you call `oh-my-zsh.sh`. This may be done by appending the following line to your `~/.zprofile` after Homebrew's initialization, instead of modifying your `~/.zshrc` as above:
```sh
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
```
You may also need to forcibly rebuild `zcompdump`:

View File

@ -28,14 +28,14 @@ In the case of Erlang, this requires renaming the file from `otp_src_R13B03` to
`brew --cache -s erlang` will print the correct name of the cached
download. This means instead of manually renaming a formula, you can
run `mv the_tarball $(brew --cache -s <formula>)`.
run `mv the_tarball "$(brew --cache -s <formula>)"`.
You can also pre-cache the download by using the command `brew fetch <formula>` which also displays the SHA-256 hash. This can be useful for updating formulae to new versions.
## Installing stuff without the Xcode CLT
```sh
brew sh # or: eval $(brew --env)
brew sh # or: eval "$(brew --env)"
gem install ronn # or c-programs
```

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BREW" "1" "August 2021" "Homebrew" "brew"
.TH "BREW" "1" "September 2021" "Homebrew" "brew"
.
.SH "NAME"
\fBbrew\fR \- The Missing Package Manager for macOS (or Linux)
@ -796,7 +796,7 @@ Search for \fItext\fR in the given database\.
Print export statements\. When run in a shell, this installation of Homebrew will be added to your \fBPATH\fR, \fBMANPATH\fR, and \fBINFOPATH\fR\.
.
.P
The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. The variable \fBHOMEBREW_SHELLENV_PREFIX\fR will be exported to avoid adding duplicate entries to the environment variables\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.profile\fR, \fB~/\.bash_profile\fR, or \fB~/\.zprofile\fR) with: \fBeval $(brew shellenv)\fR
The variables \fBHOMEBREW_PREFIX\fR, \fBHOMEBREW_CELLAR\fR and \fBHOMEBREW_REPOSITORY\fR are also exported to avoid querying them multiple times\. The variable \fBHOMEBREW_SHELLENV_PREFIX\fR will be exported to avoid adding duplicate entries to the environment variables\. Consider adding evaluation of this command\'s output to your dotfiles (e\.g\. \fB~/\.profile\fR, \fB~/\.bash_profile\fR, or \fB~/\.zprofile\fR) with: \fBeval "$(brew shellenv)"\fR
.
.SS "\fBtap\fR [\fIoptions\fR] [\fIuser\fR\fB/\fR\fIrepo\fR] [\fIURL\fR]"
Tap a formula repository\.