diff options
| author | Adam Vandenberg | 2010-04-03 11:51:46 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-04-03 11:51:46 -0700 |
| commit | e7d7cecceee839893d2afcececd4086b80aa818b (patch) | |
| tree | 0e06d06cd67512fad819dbf32b34c89538481662 /Library | |
| parent | e05c728e456d2809ef27559918b37c33e9051a41 (diff) | |
| download | brew-e7d7cecceee839893d2afcececd4086b80aa818b.tar.bz2 | |
Allow archs_for_command to take Pathnames. Fixes Homebrew/homebrew#1106.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/utils.rb | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 8ff6e8620..088aea195 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -132,23 +132,24 @@ end # returns array of architectures suitable for -arch gcc flag def archs_for_command cmd - cmd = `/usr/bin/which #{cmd}` unless Pathname.new(cmd).absolute? - cmd.gsub! ' ', '\\ ' - - IO.popen("/usr/bin/file #{cmd}").readlines.inject(%w[]) do |archs, line| - case line - when /Mach-O executable ppc/ - archs << :ppc7400 - when /Mach-O 64-bit executable ppc64/ - archs << :ppc64 - when /Mach-O executable i386/ - archs << :i386 - when /Mach-O 64-bit executable x86_64/ - archs << :x86_64 - else - archs - end + cmd = cmd.to_s # If we were passed a Pathname, turn it into a string. + cmd = `/usr/bin/which #{cmd}` unless Pathname.new(cmd).absolute? + cmd.gsub! ' ', '\\ ' # Escape spaces in the filename. + + IO.popen("/usr/bin/file #{cmd}").readlines.inject(%w[]) do |archs, line| + case line + when /Mach-O executable ppc/ + archs << :ppc7400 + when /Mach-O 64-bit executable ppc64/ + archs << :ppc64 + when /Mach-O executable i386/ + archs << :i386 + when /Mach-O 64-bit executable x86_64/ + archs << :x86_64 + else + archs end + end end # String extensions added by inreplace below. |
