Skip to content

fix(parser): close shared option-parser cluster #1301 #1302 #1304 #1306 — GNU-oracle verification - #1417

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/iss-parser-cluster
Oct 27, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/iss-parser-cluster

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Provenance: verification of the prematurely merged WIP #1391

The code for #1301 / #1302 / #1304 / #1306 landed on main through WIP #1391,
which was merged on 2026-10-27 while its own banner still read "not yet verified —
do not merge". The four issues therefore stayed open. This PR carries the deferred
verification of that cluster against a real GNU oracle, plus the one coverage gap
the verification exposed. The Fixes lines below close the cluster.

Diff vs main: one new regression test. The behavioral fixes themselves were
already merged by #1391 and are verified here, on a fresh full MSVC build of
main + this commit.

GNU oracle verification (WSL: coreutils 9.4, diffutils 3.10, grep 3.11)

#1301 — Bool long options reject =value

case GNU oracle WinuxCmd (this build)
cat --show-ends=foo f option '--show-ends' doesn't allow an argument + Try 'cat --help', rc1 same message + Try, rc1
ls --all=x . option '--all' doesn't allow an argument + Try, rc2 same shape, rc2
cat --help=foo option '--help' doesn't allow an argument + Try, rc1 same (dispatcher path)
grep --count=x f message + Usage: grep ... + Try, rc2, no hang same, rc2; regression test asserts no hang

#1302 — Int long option with empty =value no longer swallows the next argv

  • grep --max-count= -e x f now fails on the empty value (exit 2) and never
    consumes -e as the value — the issue's defect is gone.
    Regression test: grep.grep_int_long_option_empty_value_does_not_swallow_next_arg.
  • Accepted message-form delta: GNU grep validates the value in grep.c and prints
    grep: invalid max count; WinuxCmd's shared parser prints
    grep: invalid argument '' for '--max-count' + Usage/Try, also exit 2. Matching GNU
    verbatim would require the shared parser to pass unparseable ints through to every
    command's own validator — a cross-command API change out of scope here. Exit code and
    the failing operand match GNU.

#1304 — POSIXLY_CORRECT stops option permutation at the first operand

  • POSIXLY_CORRECT=1 ls . --color=never → ls: cannot access '--color=never' + . listing, rc2;
    unset → rc0. Matches the oracle exactly.
  • glibc presence rule confirmed against the oracle: POSIXLY_CORRECT= (empty value)
    also stops. Implementation checks presence (getenv(...) != nullptr) in
    option_policy_for_command, mirrored in the dispatcher pre-pass; non-getopt grammars
    (find, test/[, expr, true/false, dd) keep permuting, and per-command
    stop rules (e.g. xargs) are unaffected.
  • New in this PR: ls.ls_posixly_correct_empty_value_still_stops_at_first_operand
    pins the empty-value rule — previously only POSIXLY_CORRECT=1 was covered.

#1306 — bundled short flags no longer eaten by shared optional-argument metas

  • uniq -Dc → uniq: printing all duplicated lines and repeat counts is meaningless + Try, rc1 — matches oracle.
  • split -dl 5 f → numeric suffixes, -l takes 5 from the next argv (5-line chunks) — matches oracle.
  • diff -cu a b → issue-text correction: GNU diffutils 3.10 (oracle) prints
    diff: conflicting output style options + diff: Try 'diff --help', rc2 — it does
    not emit a unified diff as the issue body claimed. The merged implementation matches
    the oracle; diff.diff_cluster_conflicting_styles_are_an_error pins it.

Test results

  • Cluster filter (16 tests incl. the new one): 16 passed, 0 failed.
  • Full winuxcmd-tests.exe with the standing baseline exclusions
    (xargs.xargs_interactive_*, xargs.xargs_max_chars_splits_batches,
    xargs.xargs_delimiter_does_not_force_exit_if_exceeded,
    xargs.xargs_verbose_quotes_special_args_1322, *.issue_1288_*,
    find.issue_1309_*): 3341 passed, 0 failed. No new failures; the parser
    changes touch every command, so the full run is the load-bearing check.
  • i18n delta: python scripts/i18n_batch.py extract output byte-identical
    before/after this branch's change (no new or removed keys; no user-visible
    strings touched — the diff is a test-only change).

Fixes #1301
Fixes #1302
Fixes #1304
Fixes #1306

…rand (#1304)

glibc counts mere presence of POSIXLY_CORRECT (an empty value counts),
and the parser policy layer already checks presence. Pin the empty-value
rule with a regression test next to the POSIXLY_CORRECT=1 ones, closing
the last coverage gap of the parser defect cluster verification.
@caomengxuan666
caomengxuan666 merged commit 63cb45a into main Oct 27, 2026
7 of 8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/iss-parser-cluster branch October 27, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment