aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Vandenberg2010-06-07 10:40:21 -0700
committerAdam Vandenberg2010-06-07 21:43:08 -0700
commitb016c2eae516c7a631a75b41b3425c24b868b796 (patch)
treecd04e3e8112a36e4143bf7a38b9878f39df4020c
parent385e3637f2679ff2b7aa66f5ce54e1d2d6953298 (diff)
downloadbrew-b016c2eae516c7a631a75b41b3425c24b868b796.tar.bz2
Support external commands
Homebrew will now look for external commands that are +x on PATH, named as "brew-<cmd>" or "brew-<cmd>.rb" * Shell scripts are exec'd with some HOMEBREW variables set in the ENV. * Ruby scripts are require'd directly. See: http://wiki.github.com/mxcl/homebrew/external-commands
-rwxr-xr-xbin/brew17
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/brew b/bin/brew
index 3b5ac4fed..95b077251 100755
--- a/bin/brew
+++ b/bin/brew
@@ -377,6 +377,23 @@ begin
brew_doctor
else
+ # Check for an external shell command
+ if system "/usr/bin/which -s brew-#{arg}"
+ # Add some Homebrew vars to the ENV
+ ['CACHE', 'CELLAR', 'LIBRARY_PATH', 'PREFIX', 'REPOSITORY'].each do |e|
+ ENV["HOMEBREW_#{e}"] = eval("HOMEBREW_#{e}")
+ end
+ exec("brew-#{arg}", *ARGV)
+ end
+
+ # Check for an external ruby command
+ external_rb = `/usr/bin/which brew-#{arg}.rb`.chomp
+ unless external_rb.empty?
+ require external_rb
+ exit 0
+ end
+
+ # Check for git commands
if ['branch', 'checkout', 'pull', 'push', 'rebase', 'reset'].include? arg
onoe "Unknown command: #{arg} (did you mean 'git #{arg}'?)"
else