Use PATH#select.
This commit is contained in:
parent
4d5d6a65e3
commit
24f48ae7d9
@ -100,7 +100,7 @@ module Homebrew
|
|||||||
|
|
||||||
# See https://github.com/Homebrew/legacy-homebrew/pull/9986
|
# See https://github.com/Homebrew/legacy-homebrew/pull/9986
|
||||||
def check_path_for_trailing_slashes
|
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?
|
return if bad_paths.empty?
|
||||||
|
|
||||||
inject_file_list bad_paths, <<-EOS.undent
|
inject_file_list bad_paths, <<-EOS.undent
|
||||||
|
|||||||
@ -197,22 +197,23 @@ module SharedEnvExtension
|
|||||||
|
|
||||||
# @private
|
# @private
|
||||||
def userpaths!
|
def userpaths!
|
||||||
paths = PATH.new(self["PATH"]).to_a
|
path = PATH.new(self["PATH"]).select do |p|
|
||||||
# put Superenv.bin and opt path at the first
|
# put Superenv.bin and opt path at the first
|
||||||
new_paths = paths.select { |p| p.start_with?("#{HOMEBREW_REPOSITORY}/Library/ENV", "#{HOMEBREW_PREFIX}/opt") }
|
p.start_with?("#{HOMEBREW_REPOSITORY}/Library/ENV", "#{HOMEBREW_PREFIX}/opt")
|
||||||
# XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
|
end
|
||||||
new_paths << "#{HOMEBREW_PREFIX}/bin"
|
path.append(HOMEBREW_PREFIX/"bin") # XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
|
||||||
# reset of self["PATH"]
|
path.append(self["PATH"]) # reset of self["PATH"]
|
||||||
new_paths += paths
|
path.append(
|
||||||
# user paths
|
# user paths
|
||||||
new_paths += ORIGINAL_PATHS.map do |p|
|
ORIGINAL_PATHS.map do |p|
|
||||||
begin
|
begin
|
||||||
p.realpath.to_s
|
p.realpath.to_s
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end - %w[/usr/X11/bin /opt/X11/bin]
|
end - %w[/usr/X11/bin /opt/X11/bin],
|
||||||
self["PATH"] = PATH.new(new_paths.uniq)
|
)
|
||||||
|
self["PATH"] = path
|
||||||
end
|
end
|
||||||
|
|
||||||
def fortran
|
def fortran
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user