From 53589c3954294403e30dff4b0cbc2a61e05d5dbf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 3 Feb 2022 19:51:37 +0530 Subject: [PATCH] ssh kitten: Fix location of generated terminfo files on NetBSD Fixes #4622 --- docs/changelog.rst | 2 ++ kittens/ssh/main.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 458f2fdf2..bb268eba0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -80,6 +80,8 @@ Detailed list of changes - Fix a regression in the previous release that broke :opt:`active_tab_foreground` (:iss:`4620`) +- ssh kitten: Fix location of generated terminfo files on NetBSD (:iss:`4622`) + 0.24.2 [2022-02-03] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index da5e022f9..9052c0790 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -20,12 +20,16 @@ cat >$tmp << 'TERMEOF' TERMINFO TERMEOF -tic_out=$(tic -x -o $HOME/.terminfo $tmp 2>&1) +tname=.terminfo +if [ -e "/usr/share/misc/terminfo.cdb" ]; then + tname=".terminfo.cdb" +fi +tic_out=$(tic -x -o $HOME/$tname $tmp 2>&1) rc=$? rm $tmp if [ "$rc" != "0" ]; then echo "$tic_out"; exit 1; fi if [ -z "$USER" ]; then export USER=$(whoami); fi -export TERMINFO="$HOME/.terminfo" +export TERMINFO="$HOME/$tname" login_shell="" python="" @@ -109,8 +113,11 @@ import subprocess, os, sys, pwd, binascii, json # macOS ships with an ancient version of tic that cannot read from stdin, so we # create a temp file for it with NamedTemporaryFile() as tmp: + tname = '.terminfo' + if os.path.exists('/usr/share/misc/terminfo.cdb'): + tname += '.cdb' tmp.write(binascii.unhexlify('{terminfo}')) - p = subprocess.Popen(['tic', '-x', '-o', os.path.expanduser('~/.terminfo'), tmp.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(['tic', '-x', '-o', os.path.expanduser('~/' + tname), tmp.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() if p.wait() != 0: getattr(sys.stderr, 'buffer', sys.stderr).write(stdout + stderr)