ARGV - rename method that conflicts with optparse

optparse adds an "options" method to ARGV, and so does Homebrew.
Rename this method (and remove optparse blocking script) so that
Homebrew plays nicer with external Ruby software.

This fixes the issue where "gem install thin" would break
"brew server", for instance.
This commit is contained in:
Adam Vandenberg 2010-07-13 07:31:43 -07:00
parent 6612a04917
commit f990f083e8
4 changed files with 6 additions and 9 deletions

View File

@ -7,7 +7,7 @@ module HomebrewArgvExtension
@named ||= reject{|arg| arg[0..0] == '-'} @named ||= reject{|arg| arg[0..0] == '-'}
end end
def options def options_only
select {|arg| arg[0..0] == '-'} select {|arg| arg[0..0] == '-'}
end end
@ -59,7 +59,7 @@ module HomebrewArgvExtension
end end
def flag? flag def flag? flag
options.each do |arg| options_only.each do |arg|
return true if arg == flag return true if arg == flag
next if arg[1..1] == '-' next if arg[1..1] == '-'
return true if arg.include? flag[2..2] return true if arg.include? flag[2..2]

View File

@ -106,7 +106,7 @@ class FormulaInstaller
fork do fork do
begin begin
read.close read.close
exec '/usr/bin/nice', '/usr/bin/ruby', '-I', File.dirname(__FILE__), '-rinstall', f.path, '--', *ARGV.options exec '/usr/bin/nice', '/usr/bin/ruby', '-I', File.dirname(__FILE__), '-rinstall', f.path, '--', *ARGV.options_only
rescue => e rescue => e
Marshal.dump(e, write) Marshal.dump(e, write)
write.close write.close

View File

@ -1,3 +0,0 @@
# This file is put here to prevent loading of real optparse.rb,
# which killed Homebrew. Details of issue can be found here:
# http://github.com/mxcl/homebrew/issues#issue/97

View File

@ -126,7 +126,7 @@ begin
end end
elsif ARGV.named.empty? elsif ARGV.named.empty?
ENV['CLICOLOR']=nil ENV['CLICOLOR']=nil
exec 'ls', *ARGV.options<<HOMEBREW_CELLAR if HOMEBREW_CELLAR.exist? exec 'ls', *ARGV.options_only<<HOMEBREW_CELLAR if HOMEBREW_CELLAR.exist?
elsif ARGV.verbose? or not $stdout.tty? elsif ARGV.verbose? or not $stdout.tty?
exec "find", *ARGV.kegs+%w[-not -type d -print] exec "find", *ARGV.kegs+%w[-not -type d -print]
else else
@ -257,7 +257,7 @@ begin
when 'log' when 'log'
Dir.chdir HOMEBREW_REPOSITORY Dir.chdir HOMEBREW_REPOSITORY
args = ARGV.options args = ARGV.options_only
args.unshift ARGV.formulae.first.path unless ARGV.named.empty? args.unshift ARGV.formulae.first.path unless ARGV.named.empty?
exec "git", "log", *args exec "git", "log", *args
@ -276,7 +276,7 @@ begin
when 'cat' when 'cat'
Dir.chdir HOMEBREW_REPOSITORY Dir.chdir HOMEBREW_REPOSITORY
exec "cat", ARGV.formulae.first.path, *ARGV.options exec "cat", ARGV.formulae.first.path, *ARGV.options_only
when 'outdated' when 'outdated'
outdated_brews.each do |keg, name, version| outdated_brews.each do |keg, name, version|