From 4ae27b7a665afb758d0a5abf9cd8964e1bdc5c67 Mon Sep 17 00:00:00 2001 From: espie Date: Fri, 13 May 2022 15:39:14 +0000 Subject: [PATCH] Catch the termcap exception if there's a problem looking the terminal up. It's just a progressmeter after all, there's no reason to error out instead of simply devolving to "no progress meter". (as noticed working with one of my students, Matthieu Fourre, whose emulator or setup was somehow passing an "xterm-kitty" string) --- usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm index e3ec480bf1e..159822aa208 100644 --- a/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm +++ b/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Term.pm,v 1.42 2021/01/30 11:19:01 espie Exp $ +# $OpenBSD: Term.pm,v 1.43 2022/05/13 15:39:14 espie Exp $ # # Copyright (c) 2004-2007 Marc Espie # @@ -110,8 +110,18 @@ sub init return unless defined $ENV{TERM} || defined $ENV{TERMCAP}; my $termios = POSIX::Termios->new; $termios->getattr(0); - my $terminal = Term::Cap->Tgetent({ OSPEED => - $termios->getospeed}); + my $terminal; + eval { + $terminal = + Term::Cap->Tgetent({ OSPEED => $termios->getospeed}); + }; + if ($@) { + chomp $@; + $@ =~ s/\s+at\s+.*\s+line\s+.*//; + $self->{state}->errsay("No progress meter: #1", $@); + bless $self, "OpenBSD::ProgressMeter::Stub"; + return; + } $self->{glitch} = $terminal->{_xn}; $self->{cleareol} = $terminal->Tputs("ce", 1); $self->{hpa} = $terminal->Tputs("ch", 1); -- 2.20.1