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
 | 
			
		||||
      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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user