From d221818fdbd900e85015e637587783e144e8ff60 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 8 Aug 2026 00:32:03 +0000 Subject: [PATCH] =?UTF-8?q?fix(scripts):=20bump-objectui.sh=20--help=20?= =?UTF-8?q?=E7=94=A8=E5=93=A8=E5=85=B5=E5=AE=9A=E7=95=8C=EF=BC=8C=E6=94=B9?= =?UTF-8?q?=20header=20=E4=B8=8D=E5=86=8D=E9=9D=99=E9=BB=98=E6=88=AA?= =?UTF-8?q?=E6=96=AD=20(#6425)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `--help` 过去用硬编码行号 `sed -n '2,26p'` 打印自己的头注释,行号与 header 内容之间 没有任何机制耦合:往 header 加一行帮助就静默截断,删一行就越界打进下一段。两种情况都 exit 0、都打印了「一些东西」,所以截断的帮助和完整的帮助长得一模一样。 这不是假设。#5960 往 header 加了 pin 更新步骤,把真正的结尾从第 19 行推到第 26 行, PR #6421 只能手工挪这个魔法数字,并留下一条「请下一位作者注意」的 NOTE。注释不是机制。 改法是把行号换成哨兵 `# --help ends here`,让终止符与它所终止的内容放在一起: - `sed -n '2,/^# --help ends here$/p'` 取到哨兵为止。起始的 `2` 定位的是 shebang, 位置由 execve 固定,不随 header 内容漂移,因此不是会漂的行号。 - `grep -vxF` 按整行精确剔掉哨兵本身,而不是按子串过滤,header 里即便提到这句话也不会 被连带吃掉。 - 哨兵缺失时 exit 1 并说明如何恢复,而不是一路打印到 EOF(实测无此闸会吐出 231 行)。 闸只设在 --help 分支:删掉一条注释不该让真正的 pin bump 跑不起来。 同时删掉 `:66-68` 那条来自 PR #6421 的手工耦合 NOTE —— 哨兵落地后它即成假话,留着 只是把谎言搬个家。 验证:改动前后 `--help` 输出逐字节一致(25 行 / 1363 字节);往 header 加一行后新行 出现,而同一探针在旧脚本上被静默丢弃。 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01BDmDsu2575gDxeMCxXhDE3 --- scripts/bump-objectui.sh | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/scripts/bump-objectui.sh b/scripts/bump-objectui.sh index fc9b65ba0d..bf907fea77 100755 --- a/scripts/bump-objectui.sh +++ b/scripts/bump-objectui.sh @@ -24,6 +24,13 @@ # Assumes sibling layout: # ~/work/objectui # ~/work/objectstack ← run from here +# --help ends here +# +# ^ SENTINEL, not prose — `--help` prints from the shebang down to the line above +# and stops there, so the terminator travels with the text it terminates. Add or +# remove header lines freely; no line number tracks this block any more (#6425). +# Spell it exactly: the --help branch below refuses to run without it. Everything +# from here down is internal rationale and is NOT user-facing help. # # objectui ships @object-ui/console as a static SPA. The framework # release pipeline reads .objectui-sha, clones objectui at that commit, @@ -63,10 +70,25 @@ for arg in "$@"; do --no-commit) NO_COMMIT=1 ;; --no-changeset) NO_CHANGESET=1 ;; -h|--help) - # NOTE: this line range is coupled to the header block above (usage → env → - # sibling layout, ending at "run from here"). Editing the header means moving - # it — #5960 added the pin-update step and had to. - sed -n '2,26p' "$0" | sed 's/^# \{0,1\}//' + # The header block above IS the help text, and the `# --help ends here` + # sentinel is what ends it — no line range, so growing the header can no + # longer truncate the help (#6425; #5960 grew it and PR #6421 had to move a + # hand-kept `2,26p`). The leading `2` addresses the shebang, whose position + # is fixed by execve rather than by the header's content, so it cannot drift. + # + # A missing sentinel EXITS 1 rather than running on to EOF: a truncated help + # and a complete one both exit 0 and both print something, which is precisely + # why the old coupling could fail in silence — same lesson as the `head -40` + # this script used to truncate its changeset list with (#4731). Guarded here, + # not at startup: a deleted comment must never stop an actual pin bump. + if ! grep -qxF '# --help ends here' "$0"; then + echo "✗ ${0##*/}: the '# --help ends here' sentinel is missing — cannot tell" >&2 + echo " where the help text ends. Restore it at the end of the header block." >&2 + exit 1 + fi + sed -n '2,/^# --help ends here$/p' "$0" \ + | grep -vxF '# --help ends here' \ + | sed 's/^# \{0,1\}//' exit 0 ;; *) EXPLICIT_SHA="$arg" ;;