Skip to content

fix(cmds): reject bare -h for csplit/pathchk/ptx - #1593

Merged
caomengxuan666 merged 2 commits into
mainfrom
ai-fix/WinuxCmd-1591
Nov 13, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
ai-fix/WinuxCmd-1591

Conversation

@arookieofc-ai

Copy link
Copy Markdown
Contributor

Closes #1591.

Problem

GNU coreutils has no -h short option for csplit, pathchk or ptx: bare -h is invalid option -- 'h' (rc 1, probed GNU coreutils 9.4). WinuxCmd routed it into --help (rc 0) through the shared parser's default mapping, because none of the three commands registered 'h' in OPTS or joined the H_REJECT mechanism.

Fix

Register argopt::H_REJECT_SPEC in each command's OPTS and check argopt::rejected_short_h(..., 1) right after parse, before the HELP/VERSION branch — the same pattern already used by shuf, groups, nohup and who:

  • rust2/crates/winux-cmds/src/csplit.rs
  • rust2/crates/winux-cmds/src/pathchk.rs
  • rust2/crates/winux-cmds/src/ptx.rs

Regression tests

New strict gate cases via rust2/gate/gen-cases.py (regenerated TSVs, one line each):

  • cs33-short-h-rejected (-h)
  • pk31-short-h-rejected (-h)
  • px29-short-h-rejected (-h)

Verification

  • cargo fmt --check -p winux-cmds: clean.
  • Note: cargo build for the native Linux target fails on main (pre-existing: unconditional std::os::windows use in nice/nohup/timeout/test_cmd/who/winsys); the Rust build in CI runs on windows-2025, so relying on CI for the compile check here.

GNU coreutils has no -h short option for csplit, pathchk or ptx:
bare -h is 'invalid option -- '"h"'' (rc 1). WinuxCmd routed it
into --help (rc 0) via the shared parser's default mapping.

Register argopt::H_REJECT_SPEC in each command's OPTS and check
rejected_short_h() right after parse, following the shuf/groups/
nohup/who precedent. Add strict gate cases cs33/pk31/px29
(-h, mode strict) via gen-cases.py.

Closes #1591
@caomengxuan666 caomengxuan666 added bug Something isn't working compat-gap 与 GNU 行为不一致,已复现待修 labels Nov 12, 2026
@caomengxuan666 caomengxuan666 self-assigned this Nov 12, 2026
@caomengxuan666 caomengxuan666 added the P2 P2 优先级:跨盘脚本必踩的兼容缺陷 label Nov 12, 2026
@caomengxuan666

Copy link
Copy Markdown
Member

Welcome, and thank you — your first pull request to WinuxCmd, and it closes #1591 exactly as scoped.

First-pass check:

  • The mechanism exists on main with the exact signature used here (argopt::H_REJECT_SPEC, rejected_short_h(io, prog, &p, 1)), and the change mirrors the established precedent in shuf.rs — same spec registration plus the check right after parse, before the help/version branch — for all three commands.
  • Both copies of the row tables in gen-cases.py carry the new cases (cs33/pk31/px29), and the three regenerated TSVs match — no stale second definition.
  • CI was still running when I checked (all build-windows legs, oracle and baseline pending; only baseline-growth and i18n-drift green so far), and the native-Linux build caveat you note is understood — the compile check here rides on the Windows CI legs.

Per repo practice the captain reviews external PRs first — queued for captain review with CI watched. No action needed unless review asks for changes.

@caomengxuan666

Copy link
Copy Markdown
Member

Captain review — PASS ✅

Reviewed PR #1593 on its own evidence (external PR, first for #1591). The fix is correct and byte-exact against GNU coreutils 9.4 on all three commands.

What was verified

  • Mechanism: each command registers argopt::H_REJECT_SPEC and checks rejected_short_h(..., 1) right after parse, before the HELP/VERSION branch — the same established pattern as shuf/groups/who. usage_error prints exactly <prog>: invalid option -- 'h' + the try-help line to stderr.
  • GNU oracle (coreutils 9.4): csplit -h, pathchk -h, ptx -h → rc 1, empty stdout, invalid-option stderr; --help → rc 0.
  • X299 legs (PR head 27bff3d0, MSVC cl 19.44.35230, cargo/rustc 1.99.1): cargo build -p winuxcmd-driver RC=0. Direct probe of the built driver: -h → rc 1, stdout 0 bytes, stderr sha256-identical to the GNU oracle for all three commands (csplit 72B, pathchk 74B, ptx 66B); --help still rc 0. The three new gate rows (cs33/pk31/px29, strict) are well-formed; gen-cases.py re-run is a zero diff.
  • Fail-first: on base 6fc5ebf7 the driver routes -h to --help (rc 0, full help text); on the head it errors (rc 1). The fix is what changes the behaviour.
  • No regressions: cargo test -p winux-cmds is 529 passed / 4 failed on both head and base, same 4 failure names (all symlink-related: canon::dangling_tests, chown::tests::from_filter, ln::tests::symlink_mode, stat::tests::symlink_lstat) — pre-existing on this machine, not caused by this PR.
  • CI x64-default failure (23/3840): a baseline cluster — the base leg fails 23/3840 too, with a one-member Timeout-family swap under load (seq vs head fifo tests, both hitting the 120s budget). No csplit/pathchk/ptx test failed, and the new gate cases never execute in CI (no workflow runs run-gate.sh). Not a flake call — a baseline-cluster characterization with no causal path from this PR (no shared code changed).

Notes

Full evidence: ~/workspace/review-winx-1593/CAPTAIN-VERIFY.md.

Thanks for the clean, minimal fix, @arookieofc-ai. 🙏

@caomengxuan666
caomengxuan666 merged commit bb489e0 into main Nov 13, 2026
13 of 14 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 13, 2026
Re-add the 3 `short_h_is_rejected_like_gnu` unit tests (csplit/pathchk/ptx) and the 3 matching `//!` doc bullets that were held back when #1597 was closed as superseded by #1593.

What was re-added
- `rust2/crates/winux-cmds/src/csplit.rs`: 1 test + 1 doc bullet (2 `//!` lines)
- `rust2/crates/winux-cmds/src/pathchk.rs`: 1 test + 1 doc bullet
- `rust2/crates/winux-cmds/src/ptx.rs`: 1 test + 1 doc bullet
- 42 insertions, 0 deletions, 3 files. No product-code change, no workflow change.

Why now
- The product fix (argopt `H_REJECT_SPEC` + `rejected_short_h`) already landed on master via #1593 (bb489e0); only the tests + doc bullets were missing.
- PR #1605 (d2ee03f) put `cargo test -p winux-cmds` into CI (rust-tests job), so these tests will actually execute now. They were held back pending exactly that.

Evidence (X299-2607, Windows)
- Head (4bcbaf7): `cargo test -p winux-cmds short_h_is_rejected_like_gnu` -> `test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 577 filtered out`
- Base fail-first (6fc5ebf + re-add patch topped up; pre-#1593 tree without the product fix): `test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 533 filtered out`
- Fresh builds proven: distinct `Compiling winux-cmds` paths per tree, distinct test-binary sha256 (head 40cbdb41…, base 62197a84…).
- `rustfmt --check` rc=0 on all three touched files (head + base).

Notes
- The gate TSV rows + gen-cases.py rows from the original #1591 commit were deliberately NOT re-added: they belong to run-gate.sh, which is not wired into CI.
- #1597 itself stays closed (superseded); this PR only re-adds its tests/bullets.

本 PR 删除了什么
- Nothing was deleted. 42 insertions, 0 deletions.

UNVERIFIED-BY-CAPTAIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compat-gap 与 GNU 行为不一致,已复现待修 P2 P2 优先级:跨盘脚本必踩的兼容缺陷

Projects

None yet

Development

Successfully merging this pull request may close these issues.

csplit/pathchk/ptx bare -h is misrouted to --help (GNU: invalid option)

2 participants