From 17fd1a694b276d9437573277aba9798ec55e20a7 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Thu, 27 May 2021 22:00:47 +0530 Subject: [PATCH] Refactor patch_brew in darwin.sh --- src/scripts/darwin.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index c0475af6..9ea3acab 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -119,9 +119,11 @@ link_libraries() { # Patch brew to overwrite packages. patch_brew() { - sudo sed -i '' "s/ keg.link(verbose: verbose?)/ keg.link(verbose: verbose?, overwrite: true)/" "$brew_repo"/Library/Homebrew/formula_installer.rb + formula_installer="$brew_repo"/Library/Homebrew/formula_installer.rb + code=" keg.link(verbose: verbose?" + sudo sed -i '' "s/$code)/$code, overwrite: true)/" "$formula_installer" # shellcheck disable=SC2064 - trap "git -C $brew_repo stash >/dev/null 2>&1" exit + trap "sudo sed -i '' 's/$code, overwrite: true)/$code)/' $formula_installer" exit } # Helper function to update the dependencies.