From d29fa7b3820057734d8aacb1a761c24210fd0658 Mon Sep 17 00:00:00 2001 From: pagedown Date: Wed, 9 Mar 2022 16:11:58 +0800 Subject: [PATCH] ssh kitten: Add FreeBSD tcsh (csh) support Replace line feeds and exclamation marks for tcsh compatibility. --- kittens/ssh/main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index 31c01f201..41906e3bc 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -407,10 +407,11 @@ def wrap_bootstrap_script(sh_script: str, interpreter: str) -> List[str]: unwrap_script = '''"import base64, sys; eval(compile(base64.standard_b64decode(sys.argv[-1]), 'bootstrap.py', 'exec'))"''' else: # We cant rely on base64 being available on the remote system, so instead - # we quote the bootstrap script by replacing ' and \ with \v and \f and - # surrounding with ' - es = "'" + sh_script.replace("'", '\v').replace('\\', '\f') + "'" - unwrap_script = r"""'eval "$(echo "$0" | tr \\\v\\\f \\\047\\\134)"' """ + # we quote the bootstrap script by replacing ' and \ with \v and \f + # also replacing \n and ! with \r and \b for tcsh + # finally surrounding with ' + es = "'" + sh_script.replace("'", '\v').replace('\\', '\f').replace('\n', '\r').replace('!', '\b') + "'" + unwrap_script = r"""'eval "$(echo "$0" | tr \\\v\\\f\\\r\\\b \\\047\\\134\\\n\\\041)"' """ return [interpreter, '-c', unwrap_script, es]