From d7ba1380e1da738d1e614757e3a6308a891ef2ef Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 29 Jan 2022 12:11:06 -0500 Subject: display() fix when pipe errors on big docs --- gmi.pl | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'gmi.pl') diff --git a/gmi.pl b/gmi.pl index 3eb79be..baac889 100755 --- a/gmi.pl +++ b/gmi.pl @@ -686,16 +686,22 @@ sub display { $wrapper->columns($wc); } if ($use_pager) { - IO::Pager::open(my $FH) or warn($!); - for (@doc) { - _pre_block($_); - if ($pre_block) { - print $FH $_; - } - else { - print $FH $wrapper->wrap($_); + ### opening IO Pager + eval { + # catch it or big files ( >1000 lines ) will load but the script itself dies for some reason + local $SIG{PIPE} = sub { die }; + IO::Pager::open(my $FH) or warn($!); + for (@doc) { + _pre_block($_); + if ($pre_block) { + print $FH $_; + } + else { + print $FH $wrapper->wrap($_); + } } - } + close $FH; + }; } else { for (@doc) { -- cgit v1.2.3