11require "formula"
22require "compilers"
33require "development_tools"
4+ require "PATH"
45
56# Homebrew extends Ruby's `ENV` to make our code more readable.
67# Implemented in {SharedEnvExtension} and either {Superenv} or
@@ -80,7 +81,7 @@ def prepend(keys, value, separator = " ")
8081 end
8182
8283 def append_path ( key , path )
83- append key , path , File :: PATH_SEPARATOR if File . directory? path
84+ self [ key ] = PATH . new ( self [ key ] ) . append ( path )
8485 end
8586
8687 # Prepends a directory to `PATH`.
@@ -92,7 +93,7 @@ def append_path(key, path)
9293 # (e.g. <pre>ENV.prepend_path "PATH", which("emacs").dirname</pre>)
9394 def prepend_path ( key , path )
9495 return if %w[ /usr/bin /bin /usr/sbin /sbin ] . include? path . to_s
95- prepend key , path , File :: PATH_SEPARATOR if File . directory? path
96+ self [ key ] = PATH . new ( self [ key ] ) . prepend ( path )
9697 end
9798
9899 def prepend_create_path ( key , path )
@@ -196,7 +197,7 @@ def ncurses_define
196197
197198 # @private
198199 def userpaths!
199- paths = self [ "PATH" ] . split ( File :: PATH_SEPARATOR )
200+ paths = PATH . new ( self [ "PATH" ] ) . to_a
200201 # put Superenv.bin and opt path at the first
201202 new_paths = paths . select { |p | p . start_with? ( "#{ HOMEBREW_REPOSITORY } /Library/ENV" , "#{ HOMEBREW_PREFIX } /opt" ) }
202203 # XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
@@ -211,7 +212,7 @@ def userpaths!
211212 nil
212213 end
213214 end - %w[ /usr/X11/bin /opt/X11/bin ]
214- self [ "PATH" ] = new_paths . uniq . join ( File :: PATH_SEPARATOR )
215+ self [ "PATH" ] = PATH . new ( new_paths . uniq )
215216 end
216217
217218 def fortran
@@ -244,7 +245,7 @@ def fortran
244245 else
245246 if ( gfortran = which ( "gfortran" , ( HOMEBREW_PREFIX /"bin" ) . to_s ) )
246247 ohai "Using Homebrew-provided fortran compiler."
247- elsif ( gfortran = which ( "gfortran" , ORIGINAL_PATHS . join ( File :: PATH_SEPARATOR ) ) )
248+ elsif ( gfortran = which ( "gfortran" , PATH . new ( ORIGINAL_PATHS ) ) )
248249 ohai "Using a fortran compiler found at #{ gfortran } ."
249250 end
250251 if gfortran
0 commit comments