Remove "cleanpath" monkeypatch

This commit is contained in:
Jack Nagel 2014-04-20 19:57:01 -05:00
parent dfad695748
commit d1041319f4
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,7 @@
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0 #!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
require File.expand_path("../libsuperenv", File.dirname(__FILE__)) require File.expand_path("../libsuperenv", File.dirname(__FILE__))
require 'pathname'
require 'set' require 'set'
require 'stringio' require 'stringio'
@ -147,10 +148,12 @@ class Cmd
when /^-I(.+)?/ when /^-I(.+)?/
# Support both "-Ifoo" (one argument) and "-I foo" (two arguments) # Support both "-Ifoo" (one argument) and "-I foo" (two arguments)
path = $1.chuzzle || whittler.next path = $1.chuzzle || whittler.next
args << "-I#{path}" if keep?(path) and iset.add?(path.cleanpath) path = canonical_path(path)
args << "-I#{path}" if keep?(path) and iset.add?(path)
when /^-L(.+)?/ when /^-L(.+)?/
path = $1.chuzzle || whittler.next path = $1.chuzzle || whittler.next
args << "-L#{path}" if keep?(path) and lset.add?(path.cleanpath) path = canonical_path(path)
args << "-L#{path}" if keep?(path) and lset.add?(path)
else else
args << arg args << arg
end end
@ -159,7 +162,7 @@ class Cmd
end end
def keep? path def keep? path
case path.cleanpath case path
when %r{^#{Regexp.escape(brewfix)}}, %r{^#{Regexp.escape(brewtmp)}} when %r{^#{Regexp.escape(brewfix)}}, %r{^#{Regexp.escape(brewtmp)}}
# maybe homebrew is installed to /sw or /opt/brew # maybe homebrew is installed to /sw or /opt/brew
true true
@ -270,6 +273,11 @@ class Cmd
def cccfg? flags def cccfg? flags
flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG'] flags.split('').all?{|c| ENV['HOMEBREW_CCCFG'].include? c } if ENV['HOMEBREW_CCCFG']
end end
def canonical_path(path)
path = Pathname.new(path)
path = path.realpath if path.exist?
path.to_s
end
end end
if __FILE__ == $PROGRAM_NAME if __FILE__ == $PROGRAM_NAME

View File

@ -6,7 +6,6 @@
$:.unshift "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8" $:.unshift "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8"
class String class String
def cleanpath; require 'pathname'; Pathname.new(self).realpath.to_s rescue self end
def chuzzle; s = chomp; s unless s.empty? end def chuzzle; s = chomp; s unless s.empty? end
end end