From 9b0bd8166125d39fce7001fc08a100bcbb024969 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 15 Mar 2022 10:38:03 +0530 Subject: [PATCH] Ignore hostname directives when using overrides --- docs/kittens/ssh.rst | 2 +- kittens/ssh/main.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/kittens/ssh.rst b/docs/kittens/ssh.rst index bdbe4a2d0..bbeb45bb6 100644 --- a/docs/kittens/ssh.rst +++ b/docs/kittens/ssh.rst @@ -61,7 +61,7 @@ Additionally, you can pass config options on the command line: The :code:`--kitten` argument can be specified multiple times, with directives from :file:`ssh.conf`. These are merged with :file:`ssh.conf` as if they were appended to the end of that file. They apply only to the host being SSHed to -by this invocation. +by this invocation, so any :opt:`hostname` directives are ignored. .. note:: diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index cda28890b..b261947b0 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -552,7 +552,9 @@ def run_ssh(ssh_args: List[str], server_args: List[str], found_extra_args: Tuple pat = re.compile(r'^([a-zA-Z0-9_]+)[ \t]*=') for i, a in enumerate(found_extra_args): if i % 2 == 1: - overrides.append(pat.sub(r'\1 ', a.lstrip())) + aq = pat.sub(r'\1 ', a.lstrip()) + if aq.split(maxsplit=1)[0] != 'hostname': + overrides.append(aq) if overrides: overrides.insert(0, f'hostname {uname}@{hostname_for_match}') so = init_config(overrides)