doctor: simplify trailing slash checks
This commit is contained in:
parent
6a020239d1
commit
187b9c9d59
@ -41,14 +41,10 @@ end
|
|||||||
class Checks
|
class Checks
|
||||||
|
|
||||||
############# HELPERS
|
############# HELPERS
|
||||||
def remove_trailing_slash s
|
|
||||||
(s[s.length-1] == '/') ? s[0,s.length-1] : s
|
|
||||||
end
|
|
||||||
|
|
||||||
def paths
|
def paths
|
||||||
@paths ||= ENV['PATH'].split(':').collect do |p|
|
@paths ||= ENV['PATH'].split(':').collect do |p|
|
||||||
begin
|
begin
|
||||||
remove_trailing_slash(File.expand_path(p))
|
File.expand_path(p).chomp('/')
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
onoe "The following PATH component is invalid: #{p}"
|
onoe "The following PATH component is invalid: #{p}"
|
||||||
end
|
end
|
||||||
@ -72,7 +68,7 @@ class Checks
|
|||||||
# Sorry for the lack of an indent here, the diff would have been unreadable.
|
# Sorry for the lack of an indent here, the diff would have been unreadable.
|
||||||
# See https://github.com/mxcl/homebrew/pull/9986
|
# See https://github.com/mxcl/homebrew/pull/9986
|
||||||
def check_path_for_trailing_slashes
|
def check_path_for_trailing_slashes
|
||||||
bad_paths = ENV['PATH'].split(':').select{|p| p[p.length-1, p.length] == '/'}
|
bad_paths = ENV['PATH'].split(':').select { |p| p[-1..-1] == '/' }
|
||||||
return if bad_paths.empty?
|
return if bad_paths.empty?
|
||||||
s = <<-EOS.undent
|
s = <<-EOS.undent
|
||||||
Some directories in your path end in a slash.
|
Some directories in your path end in a slash.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user