From cc78050dc5607ac827429fe27686f71a7e77716c Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Sat, 3 Mar 2012 15:50:24 -0800 Subject: [PATCH] add which method --- Library/Homebrew/utils.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index e469260632..c088877403 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -138,6 +138,15 @@ def puts_columns items, star_items=[] end end +def which cmd + path = `/usr/bin/which #{cmd}`.chomp + if path.empty? + nil + else + Pathname.new(path) + end +end + def which_editor editor = ENV['HOMEBREW_EDITOR'] || ENV['EDITOR'] # If an editor wasn't set, try to pick a sane default