From f110a01ffe761ba99f4f862cf73939b2cf426c76 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 7 May 2021 11:42:52 +0530 Subject: [PATCH] Only use the last line of ssh hostname -f output incase the user has configured ssh to print random junk on login --- kittens/remote_file/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kittens/remote_file/main.py b/kittens/remote_file/main.py index d117a54ae..3d1f4c189 100644 --- a/kittens/remote_file/main.py +++ b/kittens/remote_file/main.py @@ -151,7 +151,7 @@ class ControlMaster: cp = subprocess.run(self.batch_cmd_prefix + [self.conn_data.hostname, 'hostname', '-f'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL) if cp.returncode == 0: - q = cp.stdout.decode('utf-8').strip() + q = tuple(filter(None, cp.stdout.decode('utf-8').strip().splitlines()))[-1] if not hostname_matches(self.cli_opts.hostname or '', q): print(reset_terminal(), end='') print(f'The remote hostname {styled(q, fg="green")} does not match the')