Skip to content

Commit f996495

Browse files
hotlongclaude
andauthored
fix(scripts): bump-objectui.sh --help 用哨兵定界,改 header 不再静默截断 (#6425) (#6470)
`--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 加一行后新行 出现,而同一探针在旧脚本上被静默丢弃。 Claude-Session: https://claude.ai/code/session_01BDmDsu2575gDxeMCxXhDE3 Co-authored-by: Claude <noreply@anthropic.com>
1 parent eb7613c commit f996495

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

scripts/bump-objectui.sh

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
# Assumes sibling layout:
2525
# ~/work/objectui
2626
# ~/work/objectstack ← run from here
27+
# --help ends here
28+
#
29+
# ^ SENTINEL, not prose — `--help` prints from the shebang down to the line above
30+
# and stops there, so the terminator travels with the text it terminates. Add or
31+
# remove header lines freely; no line number tracks this block any more (#6425).
32+
# Spell it exactly: the --help branch below refuses to run without it. Everything
33+
# from here down is internal rationale and is NOT user-facing help.
2734
#
2835
# objectui ships @object-ui/console as a static SPA. The framework
2936
# release pipeline reads .objectui-sha, clones objectui at that commit,
@@ -63,10 +70,25 @@ for arg in "$@"; do
6370
--no-commit) NO_COMMIT=1 ;;
6471
--no-changeset) NO_CHANGESET=1 ;;
6572
-h|--help)
66-
# NOTE: this line range is coupled to the header block above (usage → env →
67-
# sibling layout, ending at "run from here"). Editing the header means moving
68-
# it — #5960 added the pin-update step and had to.
69-
sed -n '2,26p' "$0" | sed 's/^# \{0,1\}//'
73+
# The header block above IS the help text, and the `# --help ends here`
74+
# sentinel is what ends it — no line range, so growing the header can no
75+
# longer truncate the help (#6425; #5960 grew it and PR #6421 had to move a
76+
# hand-kept `2,26p`). The leading `2` addresses the shebang, whose position
77+
# is fixed by execve rather than by the header's content, so it cannot drift.
78+
#
79+
# A missing sentinel EXITS 1 rather than running on to EOF: a truncated help
80+
# and a complete one both exit 0 and both print something, which is precisely
81+
# why the old coupling could fail in silence — same lesson as the `head -40`
82+
# this script used to truncate its changeset list with (#4731). Guarded here,
83+
# not at startup: a deleted comment must never stop an actual pin bump.
84+
if ! grep -qxF '# --help ends here' "$0"; then
85+
echo "${0##*/}: the '# --help ends here' sentinel is missing — cannot tell" >&2
86+
echo " where the help text ends. Restore it at the end of the header block." >&2
87+
exit 1
88+
fi
89+
sed -n '2,/^# --help ends here$/p' "$0" \
90+
| grep -vxF '# --help ends here' \
91+
| sed 's/^# \{0,1\}//'
7092
exit 0
7193
;;
7294
*) EXPLICIT_SHA="$arg" ;;

0 commit comments

Comments
 (0)