Skip to content

Add printf alphabet matrix (mix bash_fixtures.gen printf) - #100

Merged
davydog187 merged 1 commit into
mainfrom
cursor/printf-alphabet-matrix-23f8
Aug 23, 2026
Merged

Add printf alphabet matrix (mix bash_fixtures.gen printf)#100
davydog187 merged 1 commit into
mainfrom
cursor/printf-alphabet-matrix-23f8

Conversation

@davydog187

@davydog187 davydog187 commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Implements #70 item 2 for printf only: a generated printf_matrix suite in the same generate / record / test path as date_matrix.

The old by-example printf.json (6 cases) is unchanged. Oils builtin-printf.test.sh is a cross-check, not this matrix.

What was enumerated

mix bash_fixtures.gen printf writes 595 cases:

  • Every conversion bash/coreutils documents: %s %c %d %i %u %o %x %X %f %e %E %g %G %a %A %%, plus bash extras %b and %q
  • Each conversion at two or more bases so padding, signs, empty and zero are visible (hi vs empty, 7 vs 255, -1 vs 0)
  • Flags (-, +, space, 0, #) crossed with every conversion, and again with width 5
  • Widths 1/5/10, precisions 0/2/6 and empty %.d, plus %5.2
  • Finite * forms (%*, %.*, %*.*, flag+*) — extra arguments are the width/precision, not the value
  • %b inputs that make escapes visible (\t, \n, \x41, \101, \c)
  • %q inputs that make shell-quoting visible (empty, space, quote, $HOME, *, -n)
  • Format recycling with excess arguments (printf '%s' a b c, mixed %s:%d, %b/%q recycle)
  • Command-level cells: no operands, --, -v, -Z, %(fmt)T

mix bash_fixtures.gen printf --dry-run reports printf_matrix: 595 cases. mix bash_fixtures.gen now generates both date and printf.

Recording

Docker was not available on the agent VM. Oracle output was recorded with the same test/fixtures/runner.sh the Docker task runs, under GNU bash 5.2.21 / Ubuntu 24.04, then pretty-printed through Mix.Tasks.BashFixtures.write_json!/2:

mix bash_fixtures.gen printf
bash test/fixtures/runner.sh < test/fixtures/bash_cases/printf_matrix.json > /tmp/printf_matrix_raw.json
# then Jason-pretty-print + Fixtures.validate, as `mix bash_fixtures` does

To re-record through Docker when it is available:

mix bash_fixtures printf_matrix

\xff is not in the matrix: jq --rawfile replaces invalid UTF-8, so that cell would be a harness artifact. The existing unit test still covers it.

Known gaps (467 of 595)

No cell was omitted. Divergences are opts.known_gap (excluded from the digest). The fixture runner still executes them with the assertion inverted.

Count Reason
187 Unimplemented conversions (%i %u %E %g %G %a %A %q) passed through literally
144 * for width/precision not implemented
54 +, space, # format flags not implemented
22 %e uses Erlang ~e (exponent width / default digits differ)
18 bash rejects a flag/width/precision on %%
8 empty precision (%.d) is not parsed
6 integer precision ignored (bash: minimum digit count)
4 invalid/incomplete specifier: JustBash exits 0, bash diagnoses
4 integer operands: hex 0xff, octal 010, \'A, leading spaces
3 %o/%x/%X of -1 printed signed; bash unsigned-wraps 64-bit
3 0-padding honoured on %s/%c/%b; bash ignores 0 there
3 precision on %b ignored
2 %c of empty/missing emits nothing; bash emits NUL
2 %(fmt)T not implemented
1 %b \NNN octal (only \0NNN, matching echo -e)
1 %b \c terminator
1 %0-5d flag order not parsed
1 no operands: exit 0 vs usage/exit 2
1 -- treated as the format
1 -v treated as the format
1 -Z absorbed as the format, exit 0

JustBash.exec/2 did not raise on any cell. No printf implementation bugs were fixed in this PR — it is the enumeration + harness. Cheap follow-ups the matrix now makes un-skippable: %i as a %d alias, unsigned wrap, +/ /# flags, *, %q.

Tests

All local quality gates passed:

  • mix compile --warnings-as-errors
  • mix format --check-formatted
  • mix credo --strict (only the existing intentional banned_fixture_apply finding)
  • mix dialyzer (zero new errors)
  • mix test — 6094 tests, 0 failures
  • mix test --only suite:printf_matrix — 595 tests, 0 failures

Related Issues

Related to #70 (item 2 only; not closing the issue)

Type of Change

  • New feature (non-breaking change which adds functionality)

Testing

  • Added new tests
  • All existing tests pass
  • Tested manually (mix bash_fixtures.gen printf --dry-run, local runner.sh recording, JustBash vs oracle classification)

Checklist

  • My code follows the style guidelines of this project
  • I have run mix format
  • I have run mix credo and addressed any issues
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • I have updated the documentation accordingly
  • I have updated the CHANGELOG.md (for non-trivial changes)
Open in Web Open in Cursor 

Enumerate every documented printf conversion across flags, widths,
precisions, *, %b/%q inputs, and format recycling, the same way
date_matrix already works. Gaps are marked with reasons rather than
omitted; recordings were taken from GNU bash 5.2 via runner.sh.

Co-authored-by: Dave Lucia <davelucianyc@gmail.com>
@davydog187
davydog187 marked this pull request as ready for review August 23, 2026 14:33
@davydog187
davydog187 merged commit 8d17f74 into main Aug 23, 2026
4 checks passed
@davydog187
davydog187 deleted the cursor/printf-alphabet-matrix-23f8 branch August 23, 2026 14:41
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.

2 participants