fix: preserve cron env patch newlines
This commit is contained in:
parent
16eb283908
commit
655e20e276
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user