def which(prog, path = ENV['PATH'])
      path.split(File::PATH_SEPARATOR).each do |dir|
        if File::ALT_SEPARATOR
          ext = Win32Exts.find do |ext|
            if prog.include?('.')
              f = File.join(dir, prog)
            else
              f = File.join(dir, prog+ext)
            end
            File.executable?(f) && !File.directory?(f)
          end
          if ext
            if prog.include?('.')
              f = File.join(dir, prog).gsub(/\//,'\\')
            else
              f = File.join(dir, prog + ext).gsub(/\//,'\\')
            end
            return f
          end
        else
          f = File.join(dir, prog)
          if File.executable?(f) && !File.directory?(f)
            return File::join(dir, prog)
          end
        end
      end

      nil
    end
def which(prog, path = ENV['PATH'])
      path.split(File::PATH_SEPARATOR).each do |dir|
        if File::ALT_SEPARATOR
          ext = Win32Exts.find do |ext|
            if prog.include?('.')
              f = File.join(dir, prog)
            else
              f = File.join(dir, prog+ext)
            end
            File.executable?(f) && !File.directory?(f)
          end
          if ext
            if prog.include?('.')
              f = File.join(dir, prog).gsub(/\//,'\\')
            else
              f = File.join(dir, prog + ext).gsub(/\//,'\\')
            end
            return f
          end
        else
          f = File.join(dir, prog)
          if File.executable?(f) && !File.directory?(f)
            return File::join(dir, prog)
          end
        end
      end

      nil
    end
Looks for the first occurrence of program within path. On the pure crap
 OS, also known as Windows, it looks for executables ending with .exe,
 .bat and .com, which you may optionally include in the program name.

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

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

 @return [String, NilClass]

 @api public