Repository navigation
fix(cmds): reject bare -h for csplit/pathchk/ptx - #1593
Merged
Merged
Conversation
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
Member
|
Welcome, and thank you — your first pull request to WinuxCmd, and it closes #1591 exactly as scoped. First-pass check:
Per repo practice the captain reviews external PRs first — queued for captain review with CI watched. No action needed unless review asks for changes. |
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
Notes
Full evidence: Thanks for the clean, minimal fix, @arookieofc-ai. 🙏 |
This was referenced Nov 13, 2026
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
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 #1591.
Problem
GNU coreutils has no
-hshort option for csplit, pathchk or ptx: bare-hisinvalid 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_SPECin each command's OPTS and checkargopt::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.rsrust2/crates/winux-cmds/src/pathchk.rsrust2/crates/winux-cmds/src/ptx.rsRegression 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.cargo buildfor the native Linux target fails on main (pre-existing: unconditionalstd::os::windowsuse 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.