aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorMax Howell2010-02-18 17:15:38 +0000
committerMax Howell2010-02-18 17:16:02 +0000
commit8cdb504b149afd5b0742a31cc1f04f0cf2ea93ec (patch)
tree74ca8290cbf27df8b811f6088659ca9278a678e6 /Library/Homebrew/extend
parente0999078dc9aecb35af60f752218a0e923ff94d7 (diff)
downloadbrew-8cdb504b149afd5b0742a31cc1f04f0cf2ea93ec.tar.bz2
Fix Pathname.install for relative symlinks
If you have a bunch of symlinks and they all point at one file and you use Pathname.install on them all the error checking would fail if the file was moved before the symlinks because the symlinks would then point at a non existent file.
Diffstat (limited to 'Library/Homebrew/extend')
-rw-r--r--Library/Homebrew/extend/pathname.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 61a2a2d49..698136fcb 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -29,7 +29,12 @@ class Pathname
if src.is_a? Array
src.collect {|src| install src }
else
- raise "#{src} does not exist" unless File.exist? src
+ # if it's a symlink, don't resolve it to a file because if we are moving
+ # files one by one, it's likely we will break the symlink by moving what
+ # it points to before we move it
+ # and also broken symlinks are not the end of the world
+ raise "#{src} does not exist" unless File.symlink? src or File.exist? src
+
mkpath
if File.symlink? src
# we use the BSD mv command because FileUtils copies the target and