Skip to content
Snippets Groups Projects
Commit 24f48ae7 authored by Markus Reiter's avatar Markus Reiter
Browse files

Use `PATH#select`.

parent 4d5d6a65
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment