aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-04-28 15:07:46 +0200
committerMarkus Reiter2017-04-30 21:11:28 +0200
commit24f48ae7d9be865186728de9f6b324e32546ad36 (patch)
treede2edf228b30cb136383ee955d4ca864c81db1ed /Library
parent4d5d6a65e35f9a57139710c3dc547bfa51810630 (diff)
downloadbrew-24f48ae7d9be865186728de9f6b324e32546ad36.tar.bz2
Use `PATH#select`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/diagnostic.rb2
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb33
2 files changed, 18 insertions, 17 deletions
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index 1022e5d1d..1544e6765 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -100,7 +100,7 @@ module Homebrew
# See https://github.com/Homebrew/legacy-homebrew/pull/9986
def check_path_for_trailing_slashes
- bad_paths = PATH.new(ENV["PATH"]).select { |p| p[-1..-1] == "/" }
+ bad_paths = PATH.new(ENV["PATH"]).select { |p| p.end_with?("/") }
return if bad_paths.empty?
inject_file_list bad_paths, <<-EOS.undent
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index 6fa9b7778..b51ade48b 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -197,22 +197,23 @@ module SharedEnvExtension
# @private
def userpaths!
- paths = PATH.new(self["PATH"]).to_a
- # put Superenv.bin and opt path at the first
- new_paths = paths.select { |p| p.start_with?("#{HOMEBREW_REPOSITORY}/Library/ENV", "#{HOMEBREW_PREFIX}/opt") }
- # XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
- new_paths << "#{HOMEBREW_PREFIX}/bin"
- # reset of self["PATH"]
- new_paths += paths
- # user paths
- new_paths += ORIGINAL_PATHS.map do |p|
- begin
- p.realpath.to_s
- rescue
- nil
- end
- end - %w[/usr/X11/bin /opt/X11/bin]
- self["PATH"] = PATH.new(new_paths.uniq)
+ path = PATH.new(self["PATH"]).select do |p|
+ # put Superenv.bin and opt path at the first
+ p.start_with?("#{HOMEBREW_REPOSITORY}/Library/ENV", "#{HOMEBREW_PREFIX}/opt")
+ end
+ path.append(HOMEBREW_PREFIX/"bin") # XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
+ path.append(self["PATH"]) # reset of self["PATH"]
+ path.append(
+ # user paths
+ ORIGINAL_PATHS.map do |p|
+ begin
+ p.realpath.to_s
+ rescue
+ nil
+ end
+ end - %w[/usr/X11/bin /opt/X11/bin],
+ )
+ self["PATH"] = path
end
def fortran