From 5bcffbb5e37ae4624f24bfbae0d94cfc5a1f23f2 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 13 Jan 2010 11:14:58 +0000 Subject: Escape spaces for archs_for_command Use inject for concision. Rename to archs from arch as it returns an array. --- Library/Homebrew/utils.rb | 14 +++++++------- 1 file 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 -- cgit v1.2.3