aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/keg.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/keg.rb')
-rw-r--r--Library/Homebrew/keg.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 1e12d712e..0d9a12cc6 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -29,14 +29,18 @@ class Keg < Pathname
def unlink
n=0
- return n if !linked?
%w[bin etc lib include sbin share var].map{ |d| self/d }.each do |src|
next unless src.exist?
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.expand_path != dst.realpath
+ next
+ end
+
dst.uninstall_info if dst.to_s =~ INFOFILE_RX and ENV['HOMEBREW_KEEP_INFO']
dst.unlink
dst.parent.rmdir_if_possible