aboutsummaryrefslogtreecommitdiff
path: root/gmi.pl
diff options
context:
space:
mode:
authorjake <jake@jakes-mail.top>2022-01-29 12:11:06 -0500
committerjake <jake@jakes-mail.top>2022-01-29 12:11:06 -0500
commitd7ba1380e1da738d1e614757e3a6308a891ef2ef (patch)
tree9c662ca4d78a3a210ebe95e856eae9e391ff5797 /gmi.pl
parentb7a9e5544f5dd7e6f983625a485ff8fa46af80ae (diff)
display() fix when pipe errors on big docs
Diffstat (limited to 'gmi.pl')
-rwxr-xr-xgmi.pl24
1 files changed, 15 insertions, 9 deletions
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) {