From 29f81812ccf78c85ddac931dcfea9bfc88af82db Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 28 Oct 2017 19:49:25 +0100 Subject: [PATCH] brew.rb: cleanup PATH setup. Avoid adding all the tap commands to the PATH when not necessary. --- Library/Homebrew/brew.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 2cc339a834..e21e0bbd4f 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -50,11 +50,6 @@ begin path = PATH.new(ENV["PATH"]) homebrew_path = PATH.new(ENV["HOMEBREW_PATH"]) - # Add contributed commands to PATH before checking. - tap_cmds = Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd") - path.append(tap_cmds) - homebrew_path.append(tap_cmds) - # Add SCM wrappers. path.append(HOMEBREW_SHIMS_PATH/"scm") homebrew_path.append(HOMEBREW_SHIMS_PATH/"scm") @@ -93,8 +88,14 @@ begin system(HOMEBREW_BREW_FILE, "uninstall", "--force", "brew-cask") end - # External commands expect a normal PATH - ENV["PATH"] = homebrew_path unless internal_cmd + unless internal_cmd + # Add contributed commands to PATH before checking. + tap_cmds = Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd") + homebrew_path.append(tap_cmds) + + # External commands expect a normal PATH + ENV["PATH"] = homebrew_path + end if internal_cmd Homebrew.send cmd.to_s.tr("-", "_").downcase