brew.rb: fix overeager help flag matching

This commit is contained in:
Xu Cheng 2016-01-18 12:26:22 +08:00
parent b324d61f35
commit 27e8577f94

View File

@ -33,7 +33,7 @@ begin
trap("INT", std_trap) # restore default CTRL-C handler trap("INT", std_trap) # restore default CTRL-C handler
empty_argv = ARGV.empty? empty_argv = ARGV.empty?
help_regex = /(-h$|--help$|--usage$|-\?$|^help$)/ help_flag_list = %w[-h --help --usage -? help]
help_flag = false help_flag = false
internal_cmd = true internal_cmd = true
cmd = nil cmd = nil
@ -41,7 +41,7 @@ begin
ARGV.dup.each_with_index do |arg, i| ARGV.dup.each_with_index do |arg, i|
if help_flag && cmd if help_flag && cmd
break break
elsif arg =~ help_regex elsif help_flag_list.include? arg
help_flag = true help_flag = true
elsif !cmd elsif !cmd
cmd = ARGV.delete_at(i) cmd = ARGV.delete_at(i)