class IRB::Pager

def setup_pager

def setup_pager
  require 'shellwords'
  PAGE_COMMANDS.each do |pager|
    pager = Shellwords.split(pager)
    next if pager.empty?
    if pager.first == 'less' || pager.first == 'more'
      pager << '-R' unless pager.include?('-R')
    end
    begin
      io = IO.popen(pager, 'w')
    rescue
      next
    end
    if $? && $?.pid == io.pid && $?.exited? # pager didn't work
      next
    end
    return io
  end
  nil
end