feat!: raise the minimum bash from 3.0 to 3.2#888
Merged
Conversation
3.2 is the bash macOS ships, which is the reason for supporting an old bash at all. 3.0 (2004) and 3.1 (2005) have no practical install base, and supporting them has a real cost: they lack printf -v and +=, and predate the 3.2 change to [[ =~ ]] quoting, so a regex match behaves DIFFERENTLY across 'supported' versions. The gate compared only the major version, so every 3.x passed regardless of the declared 3.0 minimum. It now checks the minor too. Also corrects two claims in the rules that this work disproved: - perf-fork-budget.md said Bash 3.0 has no [[ =~ ]] and the grep -E fork in assert_matches was therefore mandatory. [[ =~ ]] works on a real 3.0 build; the fork follows from the house style rule preferring [ ], not from the version floor. - bash-style.md listed [[ ]] alongside genuinely 4.0+ constructs. The two are now separated, so a style preference is not mistaken for a compatibility constraint. CI builds and tests a real bash 3.2 instead of 3.0. Verified by running the unit suite under both builds in Docker, invoking the script as an argument to the old bash rather than through its shebang.
Testing a real bash 3.2 exposed a pre-existing gap rather than a regression: mocks and spies are shell functions and do not cross the process boundary into an external script on bash 3, but the skip guards only covered 3.0 (major == 3 && minor < 1). CI had only ever run 3.0, so these tests were always skipped and never ran on 3.2. Confirmed pre-existing by running tests/functional/doubles_test.sh against main under the same bash 3.2 image: it fails there identically. All four CI modes (sequential, parallel, simple parallel, strict) now pass on a real bash 3.2 build.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Breaking change. 3.2 is the bash macOS ships, which is the reason for supporting an
old bash at all. 3.0 (2004) and 3.1 (2005) have no practical install base, and supporting
them has a real cost: they lack
printf -vand+=, and predate the 3.2 change to[[ =~ ]]quoting — so at a 3.0 floor a regex match behaves differently across"supported" versions, which is worse than not supporting them.
The gate also never enforced the declared minimum: it compared only the major, so every
3.x passed.
💡 Changes
install.shto state 3.2+🔧 Two rules corrections this work forced
perf-fork-budget.mdclaimed "Bash 3.0 has no[[ =~ ]]; thegrep -Efork is mandatory".[[ =~ ]]works on a real 3.0 build. That fork follows from the house style rule preferring[ ], not from the version floor — so it is removable if the style rule is revisitedbash-style.mdlisted[[ ]]alongside genuinely 4.0+ constructs. Version constraints and style preferences are now separated, so the latter is not mistaken for the formerDocker validation must invoke the script as an argument to the old bash
(
/opt/bash-3.2/bin/bash ./bashunit …), as CI does. Usingbash -c './bashunit …'goesthrough the
#!/usr/bin/env bashshebang and silently runs the container's default bash5.x instead — I hit exactly that and re-verified everything.