aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-03-27 17:41:42 -0500
committerJack Nagel2014-03-27 17:54:07 -0500
commited0be26c779283baba0c5f00216f5587eb9a64a0 (patch)
tree4a4d38493ce1bc78a50f72207dc76479785bd697 /Library
parent02a1d718713583425463717c5e8d8328c67fd5ad (diff)
downloadbrew-ed0be26c779283baba0c5f00216f5587eb9a64a0.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')
-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