From 576ab24609d65dc6c777d9e0c67609f306c15975 Mon Sep 17 00:00:00 2001 From: pagedown Date: Wed, 16 Mar 2022 08:58:50 +0800 Subject: [PATCH] Preserve line breaks to keep the line numbers in error messages --- kittens/ssh/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index ec0938d19..f33a74706 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -233,7 +233,7 @@ def prepare_script(ans: str, replacements: Dict[str, str], script_type: str) -> if script_type == 'sh': # Remove comments and indents. The dropbear SSH server has 9000 bytes limit on ssh arguments length. # Needs to be trimmed before replacing EXEC_CMD to avoid affecting the indentation of user commands. - ans = re.sub(r'^\s*#.*\n|^\s*', '', ans, flags=re.MULTILINE) + ans = re.sub(r'^[ \t]*#.*$|^[ \t]*', '', ans, flags=re.MULTILINE) return re.sub('|'.join(fr'\b{k}\b' for k in replacements), sub, ans)