From 655e20e2763d90f371c97677b3fc134f36f03a65 Mon Sep 17 00:00:00 2001 From: zhx Date: Sat, 18 Jul 2026 19:14:05 +0800 Subject: [PATCH] fix: preserve cron env patch newlines --- monitors/yumi/chatapp_cron_deploy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monitors/yumi/chatapp_cron_deploy.py b/monitors/yumi/chatapp_cron_deploy.py index 419d995..804dad1 100644 --- a/monitors/yumi/chatapp_cron_deploy.py +++ b/monitors/yumi/chatapp_cron_deploy.py @@ -342,7 +342,9 @@ for key, value in updates.items(): output.append(f"{{key}}={{json.dumps(str(value))}}") target.parent.mkdir(parents=True, exist_ok=True) with tempfile.NamedTemporaryFile("w", encoding="utf-8", dir=target.parent, delete=False) as handle: - handle.write("\n".join(output).rstrip() + "\n") + # 这段 Python 会先嵌入外层远端 shell 模板;必须保留反斜杠,避免外层 + # f-string 把 \\n 提前展开成源码换行,导致目标机激活脚本语法错误。 + handle.write("\\n".join(output).rstrip() + "\\n") temp_name = handle.name os.chmod(temp_name, original_mode) os.replace(temp_name, target)