diff options
| author | Max Howell | 2009-05-22 16:21:10 +0100 |
|---|---|---|
| committer | Max Howell | 2009-05-22 16:23:13 +0100 |
| commit | 7b09f956642c296203ad7a3bcc205de027105360 (patch) | |
| tree | 87cecb378e8ca1008b7536a7e89ae15f678d55fd | |
| parent | 985030ad82fe94d51a1a4e96a51a62fa7c543c7f (diff) | |
| download | brew-7b09f956642c296203ad7a3bcc205de027105360.tar.bz2 | |
Made brew ln more useful
No need to specify exact versions or paths we try to be clever
| -rwxr-xr-x | Cellar/homebrew/brew | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Cellar/homebrew/brew b/Cellar/homebrew/brew index aac825708..b107b7b18 100755 --- a/Cellar/homebrew/brew +++ b/Cellar/homebrew/brew @@ -45,13 +45,28 @@ case ARGV[0] puts "#{path} removed" when 'ln' then - abort "#{ARGV[1]} is not a directory" unless File.directory? ARGV[1] + target=Pathname.new(ARGV[1]) + target=$root+'Cellar'+target unless target.exist? + + abort "#{target} is not a directory" unless target.directory? + + target=target.realpath + + if target.parent.parent == $root + # we are one dir too high + kids=target.children + abort "#{target} is empty :(" if kids.length == 0 + abort "There are multiple versions of #{target.basename} installed please specify one" if kids.length > 1 + target=target.children.first + abort "#{target} is not a directory!" unless target.directory? + elsif target.parent.parent.parent != $root + abort '#{target} is not a keg' + end - #TODO if user specifies just name and not version dir, do latest version #TODO you should mkdirs as you find them and symlink files otherwise #TODO consider using hardlinks - target=Pathname.new(ARGV[1]).realpath + n=0 target.find do |from| next if from == ARGV[1] #rubysucks |
