diff options
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 7beaba8ad..ff58aabfd 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -99,3 +99,24 @@ def exec_editor *args # we don't have to escape args, and escaping 100% is tricky 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 = `which #{cmd}` if not Pathname.new(cmd).absolute? + + IO.popen("file #{cmd}").readlines.each do |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 + end + end + + return archs +end |
