From 6e4d3c98dac4a9483fda77a001ce2146b3903f9b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Mar 2022 06:54:11 +0530 Subject: [PATCH] Ensure pw file is cleaned up on kitten exit This way it is cleaned up even if ssh fails --- kittens/ssh/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index 42813599f..f36b0d056 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -427,7 +427,10 @@ def main(args: List[str]) -> NoReturn: so = init_config(overrides) sod = {k: v._asdict() for k, v in so.items()} cmd += get_remote_command(remote_args, hostname, options_for_host(hostname_for_match, uname, so).interpreter, sod) - os.execvp('ssh', cmd) + import subprocess + with suppress(FileNotFoundError): + raise SystemExit(subprocess.run(cmd).returncode) + raise SystemExit('Could not find the ssh executable, is it in your PATH') if __name__ == '__main__':