From ab13201f8a5517a379c461767f16feafa8e01ffb Mon Sep 17 00:00:00 2001 From: "Heiko Schlittermann (HS12-RIPE)" Date: Sun, 19 Mar 2017 01:12:38 +0100 Subject: [PATCH] exigrep: use a pager if stdout is connected to a terminal --- src/src/exigrep.src | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/src/exigrep.src b/src/src/exigrep.src index b678c0584..abc6f3a31 100644 --- a/src/src/exigrep.src +++ b/src/src/exigrep.src @@ -220,6 +220,16 @@ pod2usage if not @ARGV; $pattern = shift @ARGV; $pattern = quotemeta $pattern if $args{l}; +# Start a pager if output goes to a terminal +if (-t 1) + { + foreach ($ENV{PAGER}//(), 'less', 'more') + { + open(my $pager, '|-', $_) or next; + select $pager; + last; + } +} # If file arguments are given, open each one and process according as it is # is compressed or not. -- 2.25.1