aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/pathname.rb
diff options
context:
space:
mode:
authorJack Nagel2014-03-27 17:41:42 -0500
committerJack Nagel2014-03-27 17:54:07 -0500
commit212d5dab69b88ba06d51bc796e70bba2701eee57 (patch)
treef5d34e1603d6b053ff455ef35e80e279ac1c9bb4 /Library/Homebrew/extend/pathname.rb
parentb3f479a5e8e26b943e1f99ef56c1941968987640 (diff)
downloadhomebrew-212d5dab69b88ba06d51bc796e70bba2701eee57.tar.bz2
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.
Diffstat (limited to 'Library/Homebrew/extend/pathname.rb')
-rw-r--r--Library/Homebrew/extend/pathname.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index dd95cc789..4080ea581 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