diff options
| author | Adam Vandenberg | 2012-03-03 15:50:24 -0800 |
|---|---|---|
| committer | Adam Vandenberg | 2012-03-06 06:53:06 -0800 |
| commit | cc78050dc5607ac827429fe27686f71a7e77716c (patch) | |
| tree | a154f826352e454af1257cb3fd51d40fb80939ee /Library | |
| parent | 6868bf0d6ece15d322b1766bf7ff047d4b5e7dcc (diff) | |
| download | brew-cc78050dc5607ac827429fe27686f71a7e77716c.tar.bz2 | |
add which method
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/utils.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index e46926063..c08887740 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 |
