diff options
| author | Max Howell | 2010-01-13 11:14:58 +0000 |
|---|---|---|
| committer | Max Howell | 2010-01-13 11:16:24 +0000 |
| commit | 5bcffbb5e37ae4624f24bfbae0d94cfc5a1f23f2 (patch) | |
| tree | 2175a20a99269adc0074e6ca5c3e00af517a7ed5 | |
| parent | 24b6e9c7216572b447f6594f8c1527e06ae5f410 (diff) | |
| download | brew-5bcffbb5e37ae4624f24bfbae0d94cfc5a1f23f2.tar.bz2 | |
Escape spaces for archs_for_command
Use inject for concision.
Rename to archs from arch as it returns an array.
| -rw-r--r-- | Library/Homebrew/utils.rb | 14 |
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 |
