diff options
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/link.rb | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb index e07bd2bc7..0184febaf 100644 --- a/Library/Homebrew/cmd/link.rb +++ b/Library/Homebrew/cmd/link.rb @@ -19,9 +19,11 @@ module Homebrew extend self opoo "Already linked: #{keg}" puts "To relink: brew unlink #{keg.fname} && brew link #{keg.fname}" next - end - - if mode.dry_run and mode.overwrite + elsif keg_only?(keg.fname) && !ARGV.force? + opoo "#{keg.fname} is keg-only and must be linked with --force" + puts "Note that doing so can interfere with building software." + next + elsif mode.dry_run && mode.overwrite print "Would remove:\n" do keg.link(mode) end @@ -35,16 +37,6 @@ module Homebrew extend self next end - begin - f = Formula.factory(keg.fname) - if f.keg_only? and not ARGV.force? - opoo "#{keg.fname} is keg-only and must be linked with --force" - puts "Note that doing so can interfere with building software." - next - end - rescue FormulaUnavailableError - end - keg.lock do print "Linking #{keg}... " do puts "#{keg.link(mode)} symlinks created" @@ -55,6 +47,12 @@ module Homebrew extend self private + def keg_only?(name) + Formula.factory(name).keg_only? + rescue FormulaUnavailableError + false + end + # Allows us to ensure a puts happens before the block exits so that if say, # an exception is thrown, its output starts on a new line. def print str, &block |
