Repository navigation
fix(hostid): accept only --help/--version (ho13 system-id row) - #1800
Merged
Merged
Conversation
caomengxuan666
force-pushed
the
fix/ho13-hostid-win-shape
branch
from
November 16, 2026 10:38
35c734e to
1aaccbc
Compare
parse_gnu_standard_options_only (coreutils src/hostid.c:63-65) accepts only the long forms; -V was declared as version in rust2 so the win-mode row hostid/ho13-short-version saw r_rc=0 vs c_rc=1. Oracle: hostid -V -> "invalid option -- 'V'" rc=1. hostid registers no option-table entries any more, so -V/-v fall through to argopt's getopt shape: "hostid: invalid option -- 'V'" plus the try-help line, rc 1. --help/--version keep working (the branded text is the dispatcher's job). Unit tests cover the exact stderr bytes for -V/-v and the rc-0 long form.
… fixes Review of dc4a35b against GNU hostid.c:61-72 and the live 9.4 oracle: the -V/-v rejection is correct, but two comments overclaimed. - parse_gnu_standard_options_only has no short help letter, yet a lone -h still takes argopt's bare-h -> --help mapping (rc 0). That divergence is already the hostid/ho12-short-help note row and the HELP-SURFACE RC-ONLY entry; say so instead of implying -h is rejected here. - --version returns 0 with empty stdout at this layer; the banner is still an open EMPTY-HELP gap in HELP-SURFACE.md, so the unit test pins only the status this layer owns. No behavior change.
caomengxuan666
force-pushed
the
fix/ho13-hostid-win-shape
branch
from
November 16, 2026 11:30
1aaccbc to
06bef3b
Compare
caomengxuan666
added a commit
that referenced
this pull request
Nov 16, 2026
…(Refs #1802) ## 根因 `hostid` 的 GNU 锚点是 `hostid.c:63-65` 调 `lib/long-options.c:98` `parse_gnu_standard_options_only`,optstring 为空——只有长 `--help`/`--version` 是合法选项,`-h` 是 getopt 的 `invalid option -- 'h'`(rc 1),不是 help 别名。修法前两处偏离: 1. `hostid -h` 走 argopt 的 bare-h → `--help` 映射,静默 rc 0(ho12 note 行,MASKED-DIVERGENCE)。 2. `--help`/`--version` 只返回 rc 0、不打印任何文本(HELP-SURFACE.md 的 hostid 两行 EMPTY-HELP;产品 exe 侧 dispatcher 拦截印 branded 文本,rust2 驱动/ABI 侧一直是空的)。 ## 修法(按机制,不打地鼠) - `rust2/crates/winux-cmds/src/hostid.rs`:注册共享的 `argopt::H_REJECT_SPEC` marker(ptx/who/pathchk/shuf/csplit 同款机制),parse 后 `rejected_short_h` 先于 help/version 分支报 `hostid: invalid option -- 'h'` + try-help 行、rc 1;`--help`/`--version` 按 argv 顺序取首个,打印探针实测的 GNU 9.4 文本(help 体 + `gnuhelp::footer("hostid", "hostid invocation")`,version 用 `gnuhelp::coreutils_version("hostid", "Jim Meyering")`,whoami/ptx 同款)。 - 顺序契约(#1573):`--help -h` 仍打印 help rc 0;`-h --help` 仍 rc 1。 - 门面:`gen-cases.py` ho12 `note` → `win`(#1800 的 ho13 同例),`cases/hostid.tsv` 重生成(仅此一行变);`note-registry.tsv` 删 ho12 行;`tests/unit/hostid/hostid_unit_test.cpp` 加 `-h` 拒绝钉。 ## 本 PR 删除了什么 - 删 `hostid_cmd` 里 `--help`/`--version` 只返回 `Ok(0)` 不打印的空分支,改为打印 GNU 文本;删 `long_version_is_accepted` 旧钉(它断言 `--version` 输出为空,正是 EMPTY-HELP 缺口本身)。 - 删 `note-registry.tsv` 的 hostid/ho12-short-help 注册行。 - 未删任何测试用例、未改产品代码(C++ 侧只加一枚 ctest 钉;`src/commands/hostid.cpp` 不动,dispatcher 的 sole `--help`/`--version` 拦截继续印 branded 文本);未引入 trust/签名/加载期校验机制。 ## 验证(队长已核) - X299 腿(两轮驱动):rust 钉 8/8;fail-first 实测 5/3(仅 3 新钉红);修后重跑 8/8;全 lib 1023/1023;ctest hostid 4/4;直探双腿 9 例 × 2 rc 全对;字节比对 rust 全项与 GNU 逐字节一致,cpp 除 `--help`/`--version` 品牌文本(按设计)外全项一致;plain 双腿同值 b206db09。第一轮驱动 bug(Copy-Item mtime 致 cargo 跑旧二进制、PCRE2 FetchContent 被墙、ctest 不在 PATH、Tee-Object UTF-16LE 日志)均已在第二轮修复,非产品问题;-V 小写假警报已证伪(probes2 文件污染;probes3 新鲜证据三重一致 + 钉逐字节断言 'V')。 - i18n:零新 key、零 catalog 改动、VERSION 不 bump(extract 1920 条,hostid 仅既有 extra_operand 键;diff 中 tr!/translate 0 次)。 - CI run 43874962136 / 43874962283(头 9c6ad27):仅红 process shard 一格 `xargs/xa137-signal-death(win) r_rc=123 c_rc=125`(基线)+ rust2-gate 聚合器;其余全 pass(构建 ×4、compare、oracle、baseline、baseline-growth、i18n-drift、rust-tests、其余 shards、surface-check)。 - 零交集证明:漂移 5d08469...e8b5ca6 为 4 文件(cat.cpp、file_io.cppm、cat 单测、en-US.json),与本 PR 5 文件零交集——按规矩免 update-branch 合入。 - 后续项:HELP-SURFACE.md / NOTE-QC.md 为生成物,本 PR 未手改,待有 WSL 的机器跑 gate regen 后刷新;`users -h`(us17)同类不同单。 Refs #1802
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the system-id shard's ho13-short-version(win) row (was r_rc=0 where the oracle exits 1).
coreutils src/hostid.c:63-65 delegates to parse_gnu_standard_options_only, which accepts only the LONG --help/--version — there is no short help/version letter. GNU probe (9.4):
hostid -V→hostid: invalid option -- 'V'+ try-help, rc 1hostid -v→ same for 'v', rc 1hostid --version→ version line, rc 0The rust2 parser had invented -v/-V as version aliases; removed, with the invalid-option usage-error path now matching the oracle byte-for-byte.