Skip to content

test(compat): gate the too-new bash constructs at source level#882

Merged
Chemaclass merged 1 commit into
mainfrom
test/bash-compat-gate
Jul 25, 2026
Merged

test(compat): gate the too-new bash constructs at source level#882
Chemaclass merged 1 commit into
mainfrom
test/bash-compat-gate

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

The prohibited-construct list in .claude/rules/bash-style.md was enforced by review
plus whatever the Bash 3.0 CI job happened to execute. A ${var,,} inside a rarely-taken
branch parses fine and only fails at runtime, so it could ship unnoticed.

bash_compatibility_test.sh previously contained a single test.

💡 Changes

  • Gate associative arrays, case-conversion expansion, negative array subscripts, &>>, BASHPID, mapfile/readarray, namerefs, coproc and parameter transformations at source level, independent of test coverage
  • Skip comment lines, so a construct quoted in the learn tutorial text is not an error
  • Each pattern was verified against a planted violation rather than assumed to work

Only version-breaking syntax is gated. Style preferences are excluded — notably [[ ]],
which was verified to work on real Bash 3.0 and is a house-style rule, not a
compatibility rule.

The Bash 3.0 CI job only catches a too-new construct when a test happens
to execute the line, so a ${var,,} inside a rarely-taken branch parses
fine and can ship. These greps reject the construct at source level
regardless of coverage.

Covers associative arrays, case-conversion expansion, negative array
subscripts, &>>, BASHPID, mapfile/readarray, namerefs, coproc and
parameter transformations. Each pattern was verified against a planted
violation, and comment lines are skipped so a construct quoted in the
learn tutorial text is not an error.

Only version-breaking syntax is gated. Style preferences are not
compatibility rules and are deliberately excluded -- notably [[ ]],
which works on every bash we support.
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 25, 2026
@Chemaclass Chemaclass self-assigned this Jul 25, 2026
@Chemaclass
Chemaclass merged commit 844a3c5 into main Jul 25, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the test/bash-compat-gate branch July 25, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant