diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 8ff6e8620c..088aea1955 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! ' ', '\\ ' + 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 + 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.