From ef387e67307504f41baf45a5b06a10eb82933788 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Tue, 5 Dec 2023 16:03:01 +0000 Subject: [PATCH] [ruby/irb] Pager should be disabled when TERM=dumb (https://github.com/ruby/irb/pull/800) For apps/libs that test against IRB, it's recommended to set `TERM=dumb` so they get minimum disruption from Reline's interactive-focus features. Therefore, we should follow the convention to disable pager when `TERM=dumb`. https://github.com/ruby/irb/commit/8a3002a39e --- lib/irb/pager.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/irb/pager.rb b/lib/irb/pager.rb index a0db5e93b4..d503487865 100644 --- a/lib/irb/pager.rb +++ b/lib/irb/pager.rb @@ -18,7 +18,7 @@ module IRB end def page(retain_content: false) - if IRB.conf[:USE_PAGER] && STDIN.tty? && pager = setup_pager(retain_content: retain_content) + if should_page? && pager = setup_pager(retain_content: retain_content) begin pid = pager.pid yield pager @@ -40,6 +40,10 @@ module IRB private + def should_page? + IRB.conf[:USE_PAGER] && STDIN.tty? && ENV["TERM"] != "dumb" + end + def content_exceeds_screen_height?(content) screen_height, screen_width = begin Reline.get_screen_size