Skip to content

[dispatcher] Abbreviation/help interception is arity- and boundary-blind: option values and wrapped commands' args get intercepted #1303

Closed

Description

@caomengxuan666

Summary

The dispatcher's pre-parse passes (long-option abbreviation expansion and --help/--version interception) scan every --xxx token without tracking option arity or command structure. Two observable consequences:

  1. Option values that look like options are intercepted/expanded.
    • grep --label --help -e x f — GNU treats --help as the label value and searches. WinuxCmd prints grep's own help and never searches (probe: stdout = grep usage text, rc0).
    • cp --suffix --ver a b — GNU copies with suffix value --ver. WinuxCmd: cp: option '--ver' is ambiguous; possibilities: '--verbose' '--version' + Try, exit 1, nothing copied.
  2. Wrapped commands' arguments are intercepted (dispatcher doesn't stop at the wrapped-command boundary).
    • printf 'a\n' | xargs echo --help — GNU runs echo, stdout --help a. WinuxCmd prints xargs' help; the command never executes.
    • Same shape expected for find . -exec echo --help \;, timeout 5 echo --help, env echo --version (xargs form probe-verified; the layer is shared).

Source

src/core/dispatcher.cppm: abbreviation normalization (~L1063-1145) and help/version scan (~L1158-1210) walk tokens linearly; only -- stops them. The per-command policy that does know the boundary (command_context.cppm stop_options_after_positionals, e.g. xargs) runs later, inside the handler — too late. Contrast: value consumption in the real parser (opt.cppm) is arity-aware; the dispatcher pre-passes are not.

Regression seed

  • grep --label --help -e x f (f contains x) → expect the matching line, rc0.
  • cp --suffix --ver a b → expect copy created, rc0, no stdout.
  • printf 'a\n' | xargs echo --help → expect stdout --help a, rc0.

Found by the full-audit (argument-form deep audit). All three probes verified against GNU on identical fixtures (two runs).

Activity

  1. added
    bug
    compat-gap
    on Oct 26, 2026
  2. caomengxuan666 commented on Oct 27, 2026

    @caomengxuan666
    MemberAuthor

    Verified fixed on current main (the parser/dispatcher alignment landed with #1391):

    • grep --label --help -e x treats --help as the label value and searches (probe: prints the matching line, rc0).
    • printf 'a\n' | xargs echo --help runs echo with --help a (rc0) — the wrapped-command boundary is honored; the env/timeout faces carry their own pins (env_wrapped_command_version_is_not_intercepted, timeout_wrapped_command_help_is_not_intercepted).
    • cp --suffix --ver a b no longer trips the abbreviation expander (value tokens are arity-aware).
      Closing with these probe results on the current build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugcompat-gap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions