From a5db113d91a0cc2384af210ddd33a59db12d45f7 Mon Sep 17 00:00:00 2001 From: Bob Lail Date: Tue, 8 Oct 2024 11:19:58 -0700 Subject: [PATCH] feat: Install an unlinked formula via `brew install` if `--overwrite` is passed If the intention is to overwrite any existing links, then `brew install` should go on to install over an unlinked formula --- Library/Homebrew/cmd/install.rb | 1 + Library/Homebrew/install.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index fe9ac9869e..7773958359 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -289,6 +289,7 @@ module Homebrew only_dependencies: args.only_dependencies?, force: args.force?, quiet: args.quiet?, + overwrite: args.overwrite?, ) end diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 34849222f1..f71fa8215c 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -60,7 +60,8 @@ module Homebrew fetch_head: false, only_dependencies: false, force: false, - quiet: false + quiet: false, + overwrite: false ) # head-only without --HEAD is an error if !head && formula.stable.nil? @@ -132,7 +133,7 @@ module Homebrew The currently linked version is: #{formula.linked_version} EOS end - elsif only_dependencies + elsif only_dependencies || (!formula.linked? && overwrite) msg = nil return true elsif !formula.linked? || formula.keg_only?