Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 54 additions & 48 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,43 @@ then
HOMEBREW_TEMP="${HOMEBREW_DEFAULT_TEMP}"
fi

# commands that take a single or no arguments.
# HOMEBREW_LIBRARY set by bin/brew
# shellcheck disable=SC2154
# doesn't need a default case as other arguments handled elsewhere.
# shellcheck disable=SC2249
case "$1" in
formulae)
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/formulae.sh"
homebrew-formulae
exit 0
;;
casks)
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/casks.sh"
homebrew-casks
exit 0
;;
shellenv)
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/shellenv.sh"
shift
homebrew-shellenv "$1"
exit 0
;;
esac
for arg in "$@"
do
[[ "${arg}" == "--" ]] && break

if [[ "${arg}" == "--help" || "${arg}" == "-h" || "${arg}" == "--usage" || "${arg}" == "-?" ]]
then
export HOMEBREW_HELP="1"
break
fi
done

if [[ -z "${HOMEBREW_HELP}" ]]
then
# commands that take a single or no arguments.
# HOMEBREW_LIBRARY set by bin/brew
# shellcheck disable=SC2154
# doesn't need a default case as other arguments handled elsewhere.
# shellcheck disable=SC2249
case "$1" in
formulae)
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/formulae.sh"
homebrew-formulae
exit 0
;;
casks)
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/casks.sh"
homebrew-casks
exit 0
;;
shellenv)
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/shellenv.sh"
shift
homebrew-shellenv "$1"
exit 0
;;
esac
fi

source "${HOMEBREW_LIBRARY}/Homebrew/help.sh"

Expand Down Expand Up @@ -192,19 +206,22 @@ esac
source "${HOMEBREW_LIBRARY}/Homebrew/utils/wrapper.sh"
check-brew-wrapper "$1"

# commands that take a single or no arguments and need to write to HOMEBREW_PREFIX.
# HOMEBREW_LIBRARY set by bin/brew
# shellcheck disable=SC2154
# doesn't need a default case as other arguments handled elsewhere.
# shellcheck disable=SC2249
case "$1" in
setup-ruby)
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/setup-ruby.sh"
shift
homebrew-setup-ruby "$1"
exit 0
;;
esac
if [[ -z "${HOMEBREW_HELP}" ]]
then
# commands that take a single or no arguments and need to write to HOMEBREW_PREFIX.
# HOMEBREW_LIBRARY set by bin/brew
# shellcheck disable=SC2154
# doesn't need a default case as other arguments handled elsewhere.
# shellcheck disable=SC2249
case "$1" in
setup-ruby)
source "${HOMEBREW_LIBRARY}/Homebrew/cmd/setup-ruby.sh"
shift
homebrew-setup-ruby "$1"
exit 0
;;
esac
fi

#####
##### Next, define all other helper functions.
Expand Down Expand Up @@ -852,17 +869,6 @@ EOS
fi
fi

for arg in "$@"
do
[[ "${arg}" == "--" ]] && break

if [[ "${arg}" == "--help" || "${arg}" == "-h" || "${arg}" == "--usage" || "${arg}" == "-?" ]]
then
export HOMEBREW_HELP="1"
break
fi
done

HOMEBREW_ARG_COUNT="$#"
HOMEBREW_COMMAND="$1"
shift
Expand Down Expand Up @@ -1077,7 +1083,7 @@ unset SUDO
# Remove internal variables
unset HOMEBREW_INTERNAL_ALLOW_PACKAGES_FROM_PATHS

if [[ -n "${HOMEBREW_BASH_COMMAND}" ]]
if [[ -n "${HOMEBREW_BASH_COMMAND}" ]] && [[ -z "${HOMEBREW_HELP}" ]]
then
# source rather than executing directly to ensure the entire file is read into
# memory before it is run. This makes running a Bash script behave more like
Expand Down
15 changes: 13 additions & 2 deletions Library/Homebrew/cmd/--repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,27 @@ tap_path() {

homebrew---repository() {
local tap
local taps=()

if [[ "$#" -eq 0 ]]
for arg in "$@"
do
case "${arg}" in
-d | --debug | -q | --quiet | -v | --verbose) ;;
*)
taps+=("${arg}")
;;
esac
done

if [[ "${#taps[@]}" -eq 0 ]]
then
echo "${HOMEBREW_REPOSITORY}"
return
fi

(
shopt -s extglob
for tap in "$@"
for tap in "${taps[@]}"
do
tap_path "${tap}"
done
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/cmd/--version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ homebrew-version() {
echo "Homebrew/homebrew-cask $(version_string "${HOMEBREW_CASK_REPOSITORY}")"
fi
}

homebrew---version() {
homebrew-version
}
3 changes: 3 additions & 0 deletions Library/Homebrew/cmd/which-formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ homebrew-which-formula() {
while [[ "$#" -gt 0 ]]
do
case "$1" in
-d | --debug | -q | --quiet | -v | --verbose)
shift
;;
--explain)
HOMEBREW_EXPLAIN=1
shift
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/utils/ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ If there's no Homebrew Portable Ruby available for your processor:

unset HOMEBREW_RUBY_PATH

if [[ "${HOMEBREW_COMMAND}" == "vendor-install" ]]
if [[ "${HOMEBREW_COMMAND}" == "vendor-install" && -z "${HOMEBREW_HELP}" ]]
then
return 0
fi
Expand Down
Loading