Skip to content

feat(builtins): add fmt on the vendored uutils engine - #2569

Merged
chaliy merged 1 commit into
mainfrom
claude/fmt-builtin
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/fmt-builtin

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

New fmt builtin. It fills and joins paragraphs with an optimal-fit (Knuth-Plass) line breaker vendored from uutils coreutils fmt (MIT). Supports GNU's options (-w, -g, -c, -t, -s, -u, -p, obsolete -WIDTH) plus the uutils extras (-m, -P, -x, -X, -q, -T). Width rules and error messages follow GNU: goal is 93% of the width, -g alone sets width to goal + 10, width caps at 2500.

The vendored panic!/unwrap paths became early returns. Attribution is in NOTICE and THIRD_PARTY_LICENSES.

Why

Step 4 of the level-up roadmap: fmt is one of the commands still missing. GNU fmt.c is GPL, so it can't be ported into MIT bashkit. uutils is MIT and already the source of our generated coreutils argument files (same pinned revision).

Before / After

Before:

$ printf 'a b\nc d\n\none.  two\n' | fmt
bash: fmt: command not found

After:

$ printf 'a b\nc d\n\none.  two\n' | fmt
a b c d

one.  two
$ printf 'The quick brown fox jumps over the lazy dog and keeps running far away.\n' | fmt -w 30
The quick brown fox jumps over
the lazy dog and keeps running
far away.

GNU wraps the second example as jumps / over ... keeps / running far away.. Same widths and paragraphs, but a different breaking choice. This is recorded as L-FMT-001. Of the 16 spec cases, 5 are marked bash_diff for this reason.

Risk

  • Low
  • New command only. A fmt on PATH in the VFS is now shadowed by the builtin. Fuzzed with 600 random byte inputs and option mixes: no panics.

Checklist

  • Tests added or updated (fmt.test.sh, 7 unit tests, bash comparison passes)
  • Backward compatibility considered

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit c790733 Commit Preview URL

Branch Preview URL
Oct 07 2026, 05:26 PM

@chaliy
chaliy force-pushed the claude/fmt-builtin branch 4 times, most recently from 2ab3421 to 4ab118f Compare October 7, 2026 16:34
fmt fills and joins paragraphs with the uutils coreutils fmt line breaker
(MIT, vendored linebreak.rs/parasplit.rs) and bashkit-owned option parsing
and I/O. GNU option set plus uutils extras; GNU width rules and messages.
Vendored panic!/unwrap paths became early returns. Line breaks can differ
from GNU fmt (L-FMT-001): GNU fmt.c is GPL and is not ported.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy
chaliy force-pushed the claude/fmt-builtin branch from 4ab118f to c790733 Compare October 7, 2026 17:26
@chaliy
chaliy merged commit 61cd638 into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/fmt-builtin branch October 7, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant