57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/what.rb', line 57
def What.where(program)
if search_path = ENV["PATH"]
paths = search_path.split(File::PATH_SEPARATOR)
paths.each do |path|
path.tr!('\\','/')
candidate = File.join(path, program)
return candidate if File.executable?(candidate)
if pathext = ENV["PATHEXT"]
pathexts = pathext.split(File::PATH_SEPARATOR)
pathexts.each do |ext|
candidate = File.join(path, program + ext)
return candidate if File.executable?(candidate)
end
end
end
end
nil
end
|