aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Howell2009-05-23 16:37:24 +0100
committerMax Howell2009-05-23 18:19:10 +0100
commit2a5a7545f7f3cd81f689d6f0d5706a7301f3908b (patch)
treeb0bf1576b6427e71e17d06d49819b5c08d7afab2
parent9c864343b6525d201afa1155f419a3439044495d (diff)
downloadbrew-2a5a7545f7f3cd81f689d6f0d5706a7301f3908b.tar.bz2
brew prefix command
-rwxr-xr-xCellar/homebrew/brew23
1 files changed, 23 insertions, 0 deletions
diff --git a/Cellar/homebrew/brew b/Cellar/homebrew/brew
index 794d2fe79..698bb643d 100755
--- a/Cellar/homebrew/brew
+++ b/Cellar/homebrew/brew
@@ -91,6 +91,29 @@ case ARGV[0]
when 'prune', 'pasteurize' then
puts "Pruned #{prune} files"
+ when 'prefix'
+ # Get the clean path to $prefix/Cellar/homebrew/brew/../../../
+ # Don't resolve any symlinks of that final result.
+ # Rationale: if the user calls /usr/local/bin/brew but that will resolve
+ # to /Brewery/Cellar/homebrew/brew we should give /usr/local and not
+ # /Brewery because the user probably has chosen /usr/local as the Homebrew
+ # to expose to the system.
+ if File.symlink? __FILE__
+ # using pathname as it will handle readlink returning abs or rel paths
+ d=Pathname.new(__FILE__).dirname
+ puts File.expand_path(d+File.readlink(__FILE__)+'../../../')
+ else
+ # Dir.pwd resolves the symlink :P #rubysucks
+ # we use the cwd because __FILE__ can be relative and expand_path
+ # resolves the symlink for the working directory if fed a relative path
+ # SIGH
+ cwd=Pathname.new `pwd`.strip
+ puts File.expand_path(cwd+__FILE__+'../../../')
+ end
+
+ when 'cache'
+ puts File.expand_path('~/Library/Application Support/Homebrew')
+
else
puts "usage: #{$0} [prune] [ln path] [install pkg]"
end \ No newline at end of file