diff --git a/mdTemplet/debug.md b/mdTemplet/debug.md index 3478c4a..fe1f034 100644 --- a/mdTemplet/debug.md +++ b/mdTemplet/debug.md @@ -24,6 +24,13 @@ - 原因: 前端单文件(如 Terminal.tsx 21k tokens)累积 - 规避: > 100k tokens 的仓库按子目录切片 (`repomix frontend/src -o /tmp/fe.xml`) +## sd + +### 2026-04-21 捕获组引用是 $1 不是 ${$1},字面量 $ 要写 $$ +- 症状: `sd 'pat (\w+)' '${$1}' file` 输出把 `$1` 位置变成空字符串,替换结果不对 +- 原因: sd replacement 里 `$1` 或 `${1}` 才是捕获组引用,`${$1}` 解析失败;字面 `$` 需要写 `$$` +- 规避: 想生成 `` `/api/users/${id}` `` 这类带字面 `${...}` 的输出,replacement 写作 `` `/api/users/$${$1}` ``(`$$` = 字面 `$`,`$1` = 捕获值);不确定时先用 stream 模式 `sd ... < file` 预览再 in-place + ## pkill / bash ### 2026-04-21 pkill -f 匹配自身命令行导致 shell 退出