aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/brew.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/brew.rb')
-rw-r--r--Library/Homebrew/brew.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb
index e07599ac6..7222f7e87 100644
--- a/Library/Homebrew/brew.rb
+++ b/Library/Homebrew/brew.rb
@@ -21,10 +21,11 @@ if ARGV == %w[--version] || ARGV == %w[-v]
end
def require?(path)
+ return false if path.nil?
require path
rescue LoadError => e
# we should raise on syntax errors but not if the file doesn't exist.
- raise unless e.to_s.include? path
+ raise unless e.message.include?(path)
end
begin
@@ -48,20 +49,24 @@ begin
end
path = PATH.new(ENV["PATH"])
+ homebrew_path = PATH.new(ENV["HOMEBREW_PATH"])
# Add contributed commands to PATH before checking.
- path.append(Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd"))
+ 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")
ENV["PATH"] = path
if cmd
- internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("cmd", cmd)
+ internal_cmd = require? HOMEBREW_LIBRARY_PATH/"cmd"/cmd
unless internal_cmd
- internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("dev-cmd", cmd)
+ internal_cmd = require? HOMEBREW_LIBRARY_PATH/"dev-cmd"/cmd
if internal_cmd && !ARGV.homebrew_developer?
system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config",
"--replace-all", "homebrew.devcmdrun", "true"
@@ -88,6 +93,9 @@ begin
system(HOMEBREW_BREW_FILE, "uninstall", "--force", "brew-cask")
end
+ # External commands expect a normal PATH
+ ENV["PATH"] = homebrew_path unless internal_cmd
+
if internal_cmd
Homebrew.send cmd.to_s.tr("-", "_").downcase
elsif which "brew-#{cmd}"
@@ -115,7 +123,6 @@ begin
odie "Unknown command: #{cmd}"
end
end
-
rescue UsageError => e
require "cmd/help"
Homebrew.help cmd, usage_error: e.message