From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5BD431FA17 for ; Thu, 4 Feb 2021 09:59:31 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/10] lei q: only start pager if output is to stdout Date: Thu, 4 Feb 2021 00:59:24 -0900 Message-Id: <20210204095930.20278-5-e@80x24.org> In-Reply-To: <20210204095930.20278-1-e@80x24.org> References: <20210204095930.20278-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No need to be starting a pager if we're writing to a regular file. --- lib/PublicInbox/LeiOverview.pm | 3 +-- lib/PublicInbox/LeiXSearch.pm | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm index e6bf4f2a..3125f015 100644 --- a/lib/PublicInbox/LeiOverview.pm +++ b/lib/PublicInbox/LeiOverview.pm @@ -78,9 +78,8 @@ sub new { if ($fmt =~ /\A($JSONL|(?:concat)?json)\z/) { $json = $self->{json} = ref(PublicInbox::Config->json); } - my ($isatty, $seekable); if ($dst eq '/dev/stdout') { - $isatty = -t $lei->{1}; + my $isatty = $lei->{need_pager} = -t $lei->{1}; $opt->{pretty} //= $isatty; if (!$isatty && -f _) { my $fl = fcntl($lei->{1}, F_GETFL, 0) // diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index e41d899e..0ca871ea 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -414,7 +414,7 @@ sub do_query { }; ($lei->{pkt_op_c}, $lei->{pkt_op_p}) = PublicInbox::PktOp->pair($ops); $lei->{1}->autoflush(1); - $lei->start_pager if -t $lei->{1}; + $lei->start_pager if delete $lei->{need_pager}; $lei->{ovv}->ovv_begin($lei); my $l2m = $lei->{l2m}; if ($l2m) {