]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei q: only start pager if output is to stdout
authorEric Wong <e@80x24.org>
Thu, 4 Feb 2021 09:59:24 +0000 (00:59 -0900)
committerEric Wong <e@80x24.org>
Fri, 5 Feb 2021 00:16:30 +0000 (00:16 +0000)
No need to be starting a pager if we're writing to a regular file.

lib/PublicInbox/LeiOverview.pm
lib/PublicInbox/LeiXSearch.pm

index e6bf4f2a95d0cc1788986bcd05602a9ebef5d4cd..3125f015499e5e7833f3f0036129293623e19b31 100644 (file)
@@ -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) //
index e41d899e7040da916a759dbcea4a2fbe13f9c933..0ca871ea8542e635bef78a65d387c2c9dfe0de45 100644 (file)
@@ -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) {