From: Heiko Schlittermann (HS12-RIPE) Date: Sun, 19 Mar 2017 00:12:38 +0000 (+0100) Subject: exigrep: use a pager if stdout is connected to a terminal X-Git-Tag: exim-4_90_RC1~212 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/ab13201f8a5517a379c461767f16feafa8e01ffb exigrep: use a pager if stdout is connected to a terminal --- 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.