From ed0be26c779283baba0c5f00216f5587eb9a64a0 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Thu, 27 Mar 2014 17:41:42 -0500 Subject: [PATCH] Fix overly defensive handling of src parameter in make_relative_symlink This method is for internal use only. It is unsuitable for use in formulae, which should use install_symlink to create relative symlinks. Thus callers are required to pass a Pathname, not a string, and we can remove this conditional. Further, if src is not absolute, then src.relative_path_from(dirname) will fail. All callers currently pass absolute pathnames. Therefore we don't need to call expand_path when printing it. --- Library/Homebrew/extend/pathname.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index dd95cc7899..4080ea5819 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -291,8 +291,6 @@ class Pathname # perhaps confusingly, this Pathname object becomes the symlink pointing to # the src paramter. def make_relative_symlink src - src = Pathname.new(src) unless src.kind_of? Pathname - self.dirname.mkpath Dir.chdir self.dirname do # NOTE only system ln -s will create RELATIVE symlinks @@ -300,7 +298,7 @@ class Pathname if not $?.success? if symlink? && exist? raise <<-EOS.undent - Could not symlink file: #{src.expand_path} + Could not symlink file: #{src} Target #{self} already exists as a symlink to #{readlink}. If this file is from another formula, you may need to `brew unlink` it. Otherwise, you may want to delete it. @@ -312,7 +310,7 @@ class Pathname EOS elsif exist? raise <<-EOS.undent - Could not symlink file: #{src.expand_path} + Could not symlink file: #{src} Target #{self} already exists. You may need to delete it. To force the link and overwrite all other conflicting files, do: brew link --overwrite formula_name @@ -325,12 +323,12 @@ class Pathname make_relative_symlink(src) elsif !dirname.writable_real? raise <<-EOS.undent - Could not symlink file: #{src.expand_path} + Could not symlink file: #{src} #{dirname} is not writable. You should change its permissions. EOS else raise <<-EOS.undent - Could not symlink file: #{src.expand_path} + Could not symlink file: #{src} #{self} may already exist. #{dirname} may not be writable. EOS