# File lib/facter/util/resolution.rb, line 36
36:   def self.which(bin)
37:     if absolute_path?(bin)
38:       return bin if File.executable?(bin)
39:       if Facter::Util::Config.is_windows? and File.extname(bin).empty?
40:         exts = ENV['PATHEXT']
41:         exts = exts ? exts.split(File::PATH_SEPARATOR) : %w[.COM .EXE .BAT .CMD]
42:         exts.each do |ext|
43:           destext = bin + ext
44:           if File.executable?(destext)
45:             Facter.warnonce("Using Facter::Util::Resolution.which with an absolute path like #{bin} but no fileextension is deprecated. Please add the correct extension (#{ext})")
46:             return destext
47:           end
48:         end
49:       end
50:     else
51:       search_paths.each do |dir|
52:         dest = File.join(dir, bin)
53:         if Facter::Util::Config.is_windows?
54:           dest.gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
55:           if File.extname(dest).empty?
56:             exts = ENV['PATHEXT']
57:             exts = exts ? exts.split(File::PATH_SEPARATOR) : %w[.COM .EXE .BAT .CMD]
58:             exts.each do |ext|
59:               destext = dest + ext
60:               return destext if File.executable?(destext)
61:             end
62:           end
63:         end
64:         return dest if File.executable?(dest)
65:       end
66:     end
67:     nil
68:   end