Skip to content

Fill missing coreutils gap: tee, mktemp, realpath, readlink, truncate, stat, od, shuf #1532

@chaliy

Description

@chaliy

Background

bashkit's command dispatch ends with "command not found" for several common coreutils that aren't builtins yet. The list below is small enough to share one issue and an opportunistic batch-PR or two. Each util is a straightforward application of the existing args-codegen pipeline (cargo run -p bashkit-coreutils-port -- /tmp/uutils <util> <REV>) plus a VFS-backed body.

Acceptance criteria

For each util below:

  • crates/bashkit/src/builtins/generated/<util>_args.rs generated and committed.
  • pub mod <util>_args; added to crates/bashkit/src/builtins/generated/mod.rs.
  • New crates/bashkit/src/builtins/<util>.rs (or extension of an existing topical module — e.g. tee is fine in fileops.rs).
  • Registered in interpreter/mod.rs dispatch table and crates/bashkit/src/builtins/compgen.rs allowlist.
  • Spec tests in tests/spec_cases/bash/<util>.test.sh covering happy path, at least one negative case, and unknown-flag rejection (with ### bash_diff for the clap-vs-GNU exit-code difference).
  • every_builtin_handles_bogus_flag_cleanly in builtins/mod.rs includes the util.
  • specs/implementation-status.md table updated.
  • TM-INF-022: stderr remains Display-only; no {:?} in the new module (the existing static check enforces this).
  • coreutils-args-drift.yml picks up the new generated file automatically.

Per-util scope

  • tee — write stdin to one or more VFS paths and stdout; flags -a/--append, -i/--ignore-interrupts (no-op in virtual mode, document).
  • mktemp — VFS-backed temp-file creation returning the path; flags -d/--directory, -p DIR/--tmpdir, suffix/prefix template (XXXXXX); randomness via the existing rand workspace dep. -u/--dry-run returns the would-be path without creating; document any sandbox-bound divergence.
  • realpath — VFS canonicalization; flags -e/--canonicalize-existing, -m/--canonicalize-missing, --relative-to=, --relative-base=. Symlink-following stays disabled per the existing "Intentionally Unimplemented" entry in specs/implementation-status.md; surface the divergence in spec tests using ### bash_diff.
  • readlink — VFS read of symlink target; flags -f/--canonicalize, -e, -m. Same symlink stance as realpath.
  • truncate — VFS file truncation; flag -s SIZE with K/M/G suffixes. -r REF (size of reference file) supported.
  • stat — VFS file inspection; default GNU-style output; -c FORMAT token expansion at minimum for %n %s %a %y %F. Host-only fields (%u/%U/%g/%G) read from bashkit's username/hostname env per the existing convention. Document any unsupported tokens.
  • od — byte/char dump; modes -c, -x, -An, -w, -N. Reuse byte-rendering helpers from hextools.rs where alignment lets us.
  • shuf — random shuffle of stdin lines; flags -n NUM, -i LO-HI, -r/--repeat, -e (echo args). Use the rand workspace dep already present for bot-auth.

Out of scope

  • Permission ops (chmod, chown, chgrp) — semantics need the threat model first; separate issue.
  • df/dudisk.rs already covers the common surface; verify before duplicating.
  • shred — destructive semantics not VFS-shaped.

PR strategy

Suggested grouping (no obligation):

  • PR A: tee + mktemp + truncate (all small, all fileops-shaped).
  • PR B: realpath + readlink + stat (path/inspection cluster).
  • PR C: od + shuf.

Each PR runs the full pre-PR checklist and updates coreutils-args-drift.yml's implicit util list (no edit required — the workflow grep auto-discovers).

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions