#!/usr/bin/env ruby
# 比如: which ruby
#
name = ARGV[0]
a = ENV['PATH'].split(/;/) | $:
inc = ENV['INCLUDE']
if inc
inc = inc.split(/;/)
a << inc.map{|x| x + '\\sys'}
a << inc.map{|x| x + '\\gl'}
a = a | inc
end
lib = ENV['LIB'].split(/;/) rescue []
a =a | lib
a.flatten!
a.map{|x| x.downcase! }
a.uniq!
a.each{|path|
path.gsub!(/\\/,'/')
Dir[File.join(path, '*'+name+'*')].each{|x|
print "#{x}\n"
}
}