diff options
| author | Markus Reiter | 2017-05-03 01:00:03 +0200 |
|---|---|---|
| committer | GitHub | 2017-05-03 01:00:03 +0200 |
| commit | 77b9ef84ee0025c85faa78c252291ebddc896313 (patch) | |
| tree | 26cc08d02398f5e5149377d69144ff62c2c349ee /Library/Homebrew/utils.rb | |
| parent | 7a0e5d123c42e2fb907c0ad80cfe17125d8c9d56 (diff) | |
| parent | 1be5eeec26000b881c2ec8ff53333266eedd9fff (diff) | |
| download | brew-77b9ef84ee0025c85faa78c252291ebddc896313.tar.bz2 | |
Merge pull request #2560 from reitermarkus/PATH-refactoring
Refactor PATH generation.
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index edc540c45..83b8ba342 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -190,10 +190,10 @@ module Homebrew Gem::Specification.reset # Add Gem binary directory and (if missing) Ruby binary directory to PATH. - path = ENV["PATH"].split(File::PATH_SEPARATOR) - path.unshift(RUBY_BIN) if which("ruby") != RUBY_PATH - path.unshift(Gem.bindir) - ENV["PATH"] = path.join(File::PATH_SEPARATOR) + path = PATH.new(ENV["PATH"]) + path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH + path.prepend(Gem.bindir) + ENV["PATH"] = path.existing if Gem::Specification.find_all_by_name(name, version).empty? ohai "Installing or updating '#{name}' gem" @@ -293,7 +293,7 @@ def quiet_system(cmd, *args) end def which(cmd, path = ENV["PATH"]) - path.split(File::PATH_SEPARATOR).each do |p| + PATH.new(path).each do |p| begin pcmd = File.expand_path(cmd, p) rescue ArgumentError @@ -307,7 +307,7 @@ def which(cmd, path = ENV["PATH"]) end def which_all(cmd, path = ENV["PATH"]) - path.to_s.split(File::PATH_SEPARATOR).map do |p| + PATH.new(path).map do |p| begin pcmd = File.expand_path(cmd, p) rescue ArgumentError @@ -416,7 +416,7 @@ def nostdout end def paths(env_path = ENV["PATH"]) - @paths ||= env_path.split(File::PATH_SEPARATOR).collect do |p| + @paths ||= PATH.new(env_path).collect do |p| begin File.expand_path(p).chomp("/") rescue ArgumentError |
