Repository navigation
fix(hostid): reject -h as invalid option, wire --help/--version text (Refs #1802) - #1805
Merged
Merged
Conversation
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.
Refs #1802.
根因
hostid的 GNU 锚点是hostid.c:63-65调lib/long-options.c:98parse_gnu_standard_options_only,optstring 为空——只有长--help/--version是合法选项,-h是 getopt 的invalid option -- 'h'(rc 1),不是 help 别名。修法前两处偏离:hostid -h走 argopt 的 bare-h →--help映射,静默 rc 0(ho12 note 行,MASKED-DIVERGENCE;users -h同类,us17,不在本单范围)。--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_SPECmarker(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 同款)。--help -h仍打印 help rc 0(getopt 在 --help 处即退出,后面的 token 不校验);-h --help仍 rc 1(getopt 先撞 -h)。gen-cases.pyho12note→win(rust↔cpp rc 对照;fix(hostid): accept only --help/--version (ho13 system-id row) #1800 的 ho13 同例),cases/hostid.tsv重生成(仅此一行变);note-registry.tsv删 ho12 行(note 已无标的,NOTE-QC.md 待 X299 腿重生成);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 注册行(见上)。src/commands/hostid.cpp不动,dispatcher 的 sole--help/--version拦截继续印 branded 文本);未引入 trust/签名/加载期校验机制。验证(X299-2607 腿,待补——本 PR 先开草稿)
short_h_is_invalid_option(-h/-x 逐字节 stderr + rc 1)、h_help_ordering_follows_argv、gnu_help_version_surface(--help/--version 文本起止)、既有 -V/-v/extra-operand 钉不倒退;cargo test -p winux-cmds --lib hostid(Windows)。hostid_short_h_rejected_issue1802ctest;hostid --help/--version走 dispatcher branded 文本 rc 0。run-gate.shhostid 20 行(ho12 由 note 转 win,rust↔cpp rc 1 对齐);qc_help_surface.py重扫(hostid --help/--version 由 EMPTY-HELP 转 ALIGNED,-h 由 RC-ONLY 转 ALIGNED);qc_note_audit.py重生成 NOTE-QC.md(ho12 退出清单)。oracle/):-h/-x/-v/-V 皆invalid option+ try-help、rc 1;--help/--version 文本逐字节取样。cargo test在 Linux 上 40 个 E0433(windowsinos),与本单无关;rustfmt --check 干净。UNVERIFIED-BY-CAPTAIN