Skip to content

Commit

Permalink
BUGFIX: readlink requires chdir for relative links
Browse files Browse the repository at this point in the history
Fixes Homebrew#2650 (although there is more work to be done).  The issue is that
path.readlink.exist? returned false for all relative links, because readlink
reads relative to the current working directory.  This caused relative
symlinks such as /usr/bin/tar to be deleted, because package mosh identified
/usr/bin as one of its container directories.

The simplest fix is not to use readlink at all, because path.exist?
will tell us what we want to know, independent of current dir.
  • Loading branch information
rolandwalker committed Jan 29, 2014
1 parent 0dca7d2 commit 8250494
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cask/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ def _clean_ds_store(dir)
end

def _broken_symlink?(path)
path.symlink? && !path.readlink.exist?
path.symlink? and !path.exist?
end
end

0 comments on commit 8250494

Please sign in to comment.