Repository navigation
Port ls argument surface from uutils via codegen #1531
Copy link
Copy link
Closed
Description
Background
crates/bashkit/src/builtins/ls.rs is 3,605 LoC of handwritten flag parsing — the largest single GNU-parity gap in bashkit's coreutils port table. uu_ls's uu_app() is also the largest clap definition in uutils, so this port is the natural pressure test for the codegen tool: if it survives ls, the rest of coreutils is mechanical.
The PR also forces useful upgrades to bashkit-coreutils-port if uu_ls's en-US.ftl uses Fluent placeables or selectors that the current rewriter does not yet handle.
Acceptance criteria
crates/bashkit/src/builtins/generated/ls_args.rsproduced bycargo run -p bashkit-coreutils-port -- /tmp/uutils ls <REV>. If codegen aborts withunresolved translate!()for Fluent placeables/selectors, upgrade the codegen tool to handle the casesuu_lsexercises before committing the output.pub mod ls_args;added tocrates/bashkit/src/builtins/generated/mod.rs.crates/bashkit/src/builtins/ls.rsswitches its argument parser tols_command().try_get_matches_from(...). Existing rendering logic stays put; the change is parser-only at this issue's scope.- Flags accepted by
uu_lsbut not yet implemented by bashkit return an explicit "not yet implemented" error matching the existingtac -b/-r/-spattern (no silent no-op). - GNU help layout —
Usage:first — via the same.help_template(...)chaincat.rsandtextrev.rsapply. tests/spec_cases/bash/help-flag.test.shls_helpcontinues to pass;ls_versionupdated if the version line format diverges.- Spec tests in
tests/spec_cases/bash/cover: at least three short flags fromuu_lsthat bashkit previously parsed loosely (e.g.-Q,--quoting-style=,--group-directories-first), one composite scenario, and unknown-flag rejection (with### bash_difffor the clap-vs-GNU exit-code difference). coreutils-args-drift.ymlpicks upls_argsautomatically via the existingpub mod ...grep — no workflow edit required.- Every existing
lsspec test stays green. - Compiled binary size delta on
cargo build -p bashkit-cli --releaseis reported in the PR description (the cat/tac POC was +9 KB declared-but-unused; ls is fully wired so a real number is meaningful).
Out of scope
- Implementing every
uu_lsoption (--context,--si,--block-size, full coloration). Leave them parser-accepted-with-explicit-error or wire them to existing bashkit logic only when straightforward. - Vendoring
uucore::quoting-stylefor--quoting-stylesemantics — separate question, see the module-vendor mode issue.
Open questions
- Does the codegen tool's
translate!()rewriter need to handle Fluent placeables ({ $count },{ $name }) and selectors that appear inuu_ls's about/help strings? If yes, the port-tool gets a Phase-2 enhancement before this PR can land cleanly. - The codegen output for
lsis large (hundreds of args). Measure the cost oftry_get_matches_fromon everylsinvocation against the current handwritten parser. Cachels_command()in aOnceLockif the construction overhead is meaningful.
Related
- feat(builtins): port uutils argument surfaces via codegen (POC: cat, tac) #1529 — codegen POC (cat, tac)
- Differential testing harness for ported coreutils builtins (vs. uutils binaries) #1530 — differential testing harness (will gain an
lsrow once this lands) specs/coreutils-args-port.mdcrates/bashkit/src/builtins/ls.rscrates/bashkit-coreutils-port/
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat(builtins): port ls argument surface from uutils via codegen (#1560)
feat(builtins): port ls argument surface from uutils via codegen (#1560)