From f15b631875ef19599bcb4e774d3e67596d1f93ac Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Sun, 17 Apr 2016 04:07:36 +0200 Subject: [PATCH] brew.rb: don't show help for 'brew help' Showing help makes sense for `brew help `, but showing it for `brew help` is undesirable and prevents all commands from accepting a named argument `help` (formula, tap, file name, etc.). All other help flags are still detected before *and* after the command. Closes #103. Signed-off-by: Martin Afanasjew --- Library/brew.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/brew.rb b/Library/brew.rb index 7207e22b69..38e11473c4 100644 --- a/Library/brew.rb +++ b/Library/brew.rb @@ -30,7 +30,7 @@ begin trap("INT", std_trap) # restore default CTRL-C handler empty_argv = ARGV.empty? - help_flag_list = %w[-h --help --usage -? help] + help_flag_list = %w[-h --help --usage -?] help_flag = false internal_cmd = true cmd = nil @@ -38,7 +38,11 @@ begin ARGV.dup.each_with_index do |arg, i| if help_flag && cmd break - elsif help_flag_list.include? arg + elsif help_flag_list.include?(arg) + # Option-style help: Both `--help ` and ` --help` are fine. + help_flag = true + elsif arg == "help" && !cmd + # Command-style help: `help ` is fine, but ` help` is not. help_flag = true elsif !cmd cmd = ARGV.delete_at(i)