Skip to content

Add ${var op word} alphabet matrix (mix bash_fixtures.gen varop) - #103

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

Add ${var op word} alphabet matrix (mix bash_fixtures.gen varop)#103
davydog187 merged 1 commit into
mainfrom
cursor/varop-alphabet-matrix-2435

Conversation

@davydog187

@davydog187 davydog187 commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Implements #70 item 2 for ${var op word} parameter expansion only: a generated varop_matrix suite in the same generate / record / test path as date_matrix, printf_matrix, and test_matrix.

This is not the item-3 filesystem-shape × command cube, Oils activation, or CI topology.

What was enumerated

mix bash_fixtures.gen varop writes 270 cases. Suite name is varop_matrix (not param_matrix, to keep it distinct from the hand-written parameter_expansion suite).

  • Word-taking operators: - :- = := + :+ ? :? × unset / set-empty / foo / foobar × nonempty vs empty word
  • ${v:-1} next to ${v: -1} so a parser cannot hide the colon/space distinction behind word
  • Length ${#v} at the same four states
  • Substring ${v:offset} / ${v:offset:len} including :3 (empty vs bar), :1:3, : -N, ::2, :0:-1
  • Prefix/suffix # ## % %% × literal / glob / empty pattern, plus foofoo where shortest vs longest actually splits
  • Replacement / // × first-vs-all (o occurs twice), match vs miss, delete, empty-pattern forms, and foofoo for first vs all of foo
  • set -u cells so unset-safe word-ops stay recorded next to ${#v} / substring / removal / replacement, which bash still treats as unbound
  • Every expansion is double-quoted (echo "[${v-word}]"); set +u is explicit except the nounset cells

mix bash_fixtures.gen varop --dry-run reports varop_matrix: 270 cases. mix bash_fixtures.gen now generates date, printf, test, and varop.

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 (uid ubuntu, not root), then pretty-printed through Mix.Tasks.BashFixtures.write_json!/2:

mix bash_fixtures.gen varop
bash test/fixtures/runner.sh < test/fixtures/bash_cases/varop_matrix.json > /tmp/varop_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 varop_matrix

Known gaps (18 of 270)

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
9 ${v?} / ${v:?} returns empty and continues; bash writes a diagnostic and aborts
4 set -u on ${#v} / ${v:0} / ${v#x} / ${v/x/y} of unset: JustBash treats empty; bash errors unbound variable
4 Shortest #* / %* consumes one character; bash's shortest * match is empty so the value is unchanged
1 ${v:0:-1} on empty is empty at exit 0; bash errors substring expression < 0

Matching siblings are left unmarked (for example ${v?} on a set value, ${v##*}, ${v:0:-1} on foo).

JustBash.exec/2 did not raise on any cell. No expansion implementation bugs were fixed in this PR — it is the enumeration + harness.

Cheap follow-ups the matrix now makes un-skippable

  • ${v?} / ${v:?} should write the diagnostic and abort
  • set -u should error on ${#unset} / ${unset:offset} / ${unset#pat} / ${unset/pat}
  • Shortest #* / %* should match the empty string
  • Negative substring length on an empty value should be a diagnostic, not silent empty

Not in this PR: the item-3 FS-shape × command cube, Oils activation, CI topology changes.

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 — 6622 tests, 0 failures
  • mix bash_fixtures.gen varop --dry-runvarop_matrix: 270 cases

Related Issues

Related to #70 (item 2, ${var op word} 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 varop --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 POSIX/bash parameter-expansion forms crossed with
unset/empty/foo/foobar for #70 item 2. Record gaps with reasons;
do not omit cells.

Co-authored-by: Dave Lucia <davelucianyc@gmail.com>
@davydog187
davydog187 marked this pull request as ready for review August 23, 2026 15:13
@davydog187
davydog187 merged commit 3bf997d into main Aug 23, 2026
4 checks passed
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