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)