data-gen-bpu/docs/memory/never-edit-running-script.md
bench e030719b4d docs: 经验记忆入库(docs/memory/),根 AGENTS.md 指向它
docs/memory/AGENTS.md 写了怎么读、怎么新建、不能写什么、怎么和本机副本同步,以及索引。
推送前已核对:只有变量名,没有密钥或密钥片段。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 13:24:24 +08:00

12 lines
852 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
name: never-edit-running-script
description: 不要原地改正在运行的 shell 脚本;要改就写新文件或"新文件+改名替换"
metadata:
type: feedback
---
不要原地修改正在执行的 bash 脚本(open(p,"w") / sed -i 都会改同一个 inode)。bash 边读边执行,运行中的进程会在下一段按旧字节偏移去读已变化的内容,行为不可预测。
**Why:** 2026-10-09 我在 120 上原地改了正在跑的 `/root/salty-migrate-20261009/migrate.sh` 的 up(),"salty迁移"会话指出后只能结束主 bash,改用新脚本 phase2.sh / verify.sh 接手,我的改动也就作废了。
**How to apply:** 脚本已在运行时,改动写进新文件(或写好后 `mv` 替换,旧进程继续持有旧 inode),并明确下一轮用哪个文件。相关:[[salty-personal-migration-20261009]]