def whereis(prog, path=ENV['PATH'])
      dirs = []
      path.split(File::PATH_SEPARATOR).each do |dir|
        if File::ALT_SEPARATOR
          if prog.include?('.')
            f = File.join(dir,prog)
            if File.executable?(f) && !File.directory?(f)
              if block_given?
                yield f.gsub(/\//,'\\')
              else
                dirs << f.gsub(/\//,'\\')
              end
            end
          else
            Win32Exts.find_all do |ext|
              f = File.join(dir,prog+ext)
              if File.executable?(f) && !File.directory?(f)
                  if block_given?
                    yield f.gsub(/\//,'\\')
                  else
                    dirs << f.gsub(/\//,'\\')
                  end
                end
              end
            end
          else
            f = File.join(dir,prog)
            if File.executable?(f) && !File.directory?(f)
              if block_given?
                yield f
              else
                dirs << f
              end
            end
          end
        end
      dirs.empty? ? nil : dirs
    end
def whereis(prog, path=ENV['PATH'])
      dirs = []
      path.split(File::PATH_SEPARATOR).each do |dir|
        if File::ALT_SEPARATOR
          if prog.include?('.')
            f = File.join(dir,prog)
            if File.executable?(f) && !File.directory?(f)
              if block_given?
                yield f.gsub(/\//,'\\')
              else
                dirs << f.gsub(/\//,'\\')
              end
            end
          else
            Win32Exts.find_all do |ext|
              f = File.join(dir,prog+ext)
              if File.executable?(f) && !File.directory?(f)
                  if block_given?
                    yield f.gsub(/\//,'\\')
                  else
                    dirs << f.gsub(/\//,'\\')
                  end
                end
              end
            end
          else
            f = File.join(dir,prog)
            if File.executable?(f) && !File.directory?(f)
              if block_given?
                yield f
              else
                dirs << f
              end
            end
          end
        end
      dirs.empty? ? nil : dirs
    end
In block form, yields each program within path. In non-block form,
 returns an array of each program within path. Returns nil if not found
 found. On the Shit for Windows platform, it looks for executables
 ending with .exe, .bat and .com, which you may optionally include in
 the program name.

 @example
   whereis('ruby')
     # => [
         [0] "/opt/chefdk/embedded/bin/ruby",
         [1] "/usr/bin/ruby",
         [2] "/Users/sharding/.rvm/rubies/ruby-2.2.0/bin/ruby",
         [3] "/usr/bin/ruby"
     ]

 @param [String] cmd
   The name of the command to find.

 @param [String] path
   The path to search for the command.

 @return [String, Array, NilClass]

 @api public