aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMisty De Meo2012-10-04 08:52:48 -0500
committerMisty De Meo2012-10-04 21:37:36 -0500
commitb11de180536d537f5fcef24aa983b56948c253d7 (patch)
treeb031850179a708713d1409d2bf429939987d3aec /Library
parent867f1dd858cb6b6295304c10ab6cba31505d52c8 (diff)
downloadhomebrew-b11de180536d537f5fcef24aa983b56948c253d7.tar.bz2
Keg#unlink: check file comes from the right keg
For real this time. This makes sure that files won't be unlinked if they resolve into other kegs. For example: if fish and fishfish are both installed, with fishfish linked and fish unlinked, `brew unlink fish` would unlink some files that resolve into fishfish's keg.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/keg.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 3bae92605..76e02b629 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -34,7 +34,12 @@ class Keg < Pathname
src.find do |src|
next if src == self
dst=HOMEBREW_PREFIX+src.relative_path_from(self)
- next unless dst.symlink?
+
+ # check whether the file to be unlinked is from the current keg first
+ if !dst.symlink? || !dst.exist? || src != dst.resolved_path
+ next
+ end
+
dst.uninstall_info if dst.to_s =~ INFOFILE_RX and ENV['HOMEBREW_KEEP_INFO']
dst.unlink
dst.parent.rmdir_if_possible
@@ -79,6 +84,8 @@ class Keg < Pathname
def link mode=nil
raise "Cannot link #{fname}\nAnother version is already linked: #{linked_keg_record.realpath}" if linked_keg_record.directory?
+ # these are used by the ObserverPathnameExtension to count the number
+ # of files and directories linked
$n=0
$d=0