aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2010-01-13 11:14:58 +0000
committerMax Howell2010-01-13 11:16:24 +0000
commit5bcffbb5e37ae4624f24bfbae0d94cfc5a1f23f2 (patch)
tree2175a20a99269adc0074e6ca5c3e00af517a7ed5 /Library
parent24b6e9c7216572b447f6594f8c1527e06ae5f410 (diff)
downloadbrew-5bcffbb5e37ae4624f24bfbae0d94cfc5a1f23f2.tar.bz2
Escape spaces for archs_for_command
Use inject for concision. Rename to archs from arch as it returns an array.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/utils.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 38e9de0f8..24b1b9ea6 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -134,12 +134,12 @@ def exec_editor *args
exec *(editor.split+args)
end
-# provide an absolute path to a command or this function will search the PATH
-def arch_for_command cmd
- archs = []
- cmd = `/usr/bin/which #{cmd}` if not Pathname.new(cmd).absolute?
+# 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.each do |line|
+ IO.popen("/usr/bin/file #{cmd}").readlines.inject(%w[]) do |archs, line|
case line
when /Mach-O executable ppc/
archs << :ppc7400
@@ -149,10 +149,10 @@ def arch_for_command cmd
archs << :i386
when /Mach-O 64-bit executable x86_64/
archs << :x86_64
+ else
+ archs
end
end
-
- return archs
end
# replaces before with after for the file path