From 00d2a8527f55aede13e0506dfec028d1b33a9cf0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 6 Mar 2022 15:05:40 +0530 Subject: [PATCH] Fix parsing of env vars in bootstrap.py --- shell-integration/ssh/bootstrap.py | 9 ++++++++- shell-integration/ssh/bootstrap.sh | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/shell-integration/ssh/bootstrap.py b/shell-integration/ssh/bootstrap.py index 9a5b1fea6..2c7f0a981 100644 --- a/shell-integration/ssh/bootstrap.py +++ b/shell-integration/ssh/bootstrap.py @@ -9,6 +9,7 @@ import io import os import pwd import select +import shlex import shutil import subprocess import sys @@ -62,7 +63,12 @@ def send_data_request(): def debug(msg): - write_all(tty_fd, dcs_to_kitty('print', 'debug: {}'.format(msg))) + data = dcs_to_kitty('print', 'debug: {}'.format(msg)) + if tty_fd == -1: + with open(os.ctermid(), 'wb') as fl: + write_all(fl.fileno(), data) + else: + write_all(tty_fd, data) def apply_env_vars(raw): @@ -74,6 +80,7 @@ def apply_env_vars(raw): key, val = parts[0], '' else: key, val = parts + val = shlex.split(val)[0] os.environ[key] = val for line in raw.splitlines(): diff --git a/shell-integration/ssh/bootstrap.sh b/shell-integration/ssh/bootstrap.sh index e6500be0b..fc43909d7 100644 --- a/shell-integration/ssh/bootstrap.sh +++ b/shell-integration/ssh/bootstrap.sh @@ -73,7 +73,7 @@ else } fi -debug() { dcs_to_kitty "print" "debug $1"; } +debug() { dcs_to_kitty "print" "debug: $1"; } echo_via_kitty() { dcs_to_kitty "echo" "$1"; } if [ -z "$HOSTNAME" ]; then