aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/brew.rb9
-rw-r--r--Library/Homebrew/brew.sh10
2 files changed, 13 insertions, 6 deletions
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb
index 985a93de9..4ab360995 100644
--- a/Library/Homebrew/brew.rb
+++ b/Library/Homebrew/brew.rb
@@ -32,20 +32,17 @@ begin
empty_argv = ARGV.empty?
help_flag_list = %w[-h --help --usage -?]
- help_flag = false
+ help_flag = !ENV["HOMEBREW_HELP"].nil?
internal_cmd = true
cmd = nil
ARGV.dup.each_with_index do |arg, i|
break if help_flag && cmd
- if help_flag_list.include?(arg)
- # Option-style help: Both `--help <cmd>` and `<cmd> --help` are fine.
- help_flag = true
- elsif arg == "help" && !cmd
+ if arg == "help" && !cmd
# Command-style help: `help <cmd>` is fine, but `<cmd> help` is not.
help_flag = true
- elsif !cmd
+ elsif !cmd && !help_flag_list.include?(arg)
cmd = ARGV.delete_at(i)
end
end
diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh
index 1ccd8832a..8ffee44b3 100644
--- a/Library/Homebrew/brew.sh
+++ b/Library/Homebrew/brew.sh
@@ -183,6 +183,15 @@ then
set -- "$@" -v
fi
+for arg in "$@"
+do
+ if [[ $arg = "--help" || $arg = "-h" || $arg = "--usage" || $arg = "-?" ]]
+ then
+ export HOMEBREW_HELP="1"
+ break
+ fi
+done
+
HOMEBREW_ARG_COUNT="$#"
HOMEBREW_COMMAND="$1"
shift
@@ -272,6 +281,7 @@ setup-analytics
report-analytics-screenview-command
update-preinstall() {
+ [[ -z "$HOMEBREW_HELP" ]] || return
[[ -z "$HOMEBREW_NO_AUTO_UPDATE" ]] || return
[[ -z "$HOMEBREW_UPDATE_PREINSTALL" ]] || return