diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2023-11-06 08:13:02 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2023-11-06 08:13:02 +0000 |
commit | 8e34440ce86abfc9f189f4b7f28edc0617f335f7 (patch) | |
tree | 7cbeaba9050e402a7bb9c4635f43454ae11c3c98 /gnu/usr.bin/perl | |
parent | 237cbe07181bb7e4ae4514891a79f5e9d894c407 (diff) |
always try to run info_cmp at the end if we haven't got what we wanted
This allows terminals with only terminfo capabilities to show up in
Term::Cap (like kitty) !
Diffstat (limited to 'gnu/usr.bin/perl')
-rw-r--r-- | gnu/usr.bin/perl/cpan/Term-Cap/Cap.pm | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/gnu/usr.bin/perl/cpan/Term-Cap/Cap.pm b/gnu/usr.bin/perl/cpan/Term-Cap/Cap.pm index 5d3d296a17e..f6fb5660700 100644 --- a/gnu/usr.bin/perl/cpan/Term-Cap/Cap.pm +++ b/gnu/usr.bin/perl/cpan/Term-Cap/Cap.pm @@ -274,6 +274,7 @@ sub Tgetent $state = 1; # 0 == finished # 1 == next file # 2 == search again + # 3 == try infocmp $first = 0; # first entry (keeps term name) @@ -296,22 +297,30 @@ sub Tgetent while ( $state != 0 ) { - if ( $state == 1 ) - { - + if ( $state == 1 ) { # get the next TERMCAP - $TERMCAP = shift @termcap_path - || croak "failed termcap lookup on $tmp_term"; - } - else - { - + $TERMCAP = shift @termcap_path or $state = 3; + } elsif ($state == 3) { + croak "failed termcap lookup on $tmp_term"; + } else { # do the same file again - # prevent endless recursion $state = 1; # ok, maybe do a new file next time } - open(my $fh, '<', $TERMCAP) || croak "open $TERMCAP: $!"; + my ($fh, $child); + if ($state == 3) { + # need to do a proper fork, so that we can pass tmp_term + # without having to quote it. + $child = open($fh, "-|"); + warn "cannot run infocmp: $!" if !defined $child; + if (!$child) { + open(STDERR, ">", "/dev/null"); + system('infocmp', '-CTr', $tmp_term); + exit(1); + } + } else { + open($fh, '<', $TERMCAP) || croak "open $TERMCAP: $!"; + } while (<$fh>) { next if /^\t/ || /^#/; if (m/(^|\|)\Q$tmp_term\E[:|]/) { @@ -329,6 +338,7 @@ sub Tgetent defined $entry or $entry = ''; $entry .= $_ if $_; close $fh; + waitpid($child, 0) if defined $child; # If :tc=...: found then search this file again while ($entry =~ s/:tc=([^:]+):/:/) { |