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
commit672b675c6606edf4eddb69e48f4489f63b511156 (patch)
treee4c39833215ab2609973dd173a77e0a67ee73a90 /Library
parent79766ede79650f10b576aa3a76d6eda66210ca90 (diff)
downloadhomebrew-672b675c6606edf4eddb69e48f4489f63b511156.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