| Q |
A |
| OS |
macOS and Linux |
| Shell & version |
bash 3.0 / 3.2 / 5.2 |
| bashunit version |
0.50.1 |
Summary
A comment in assert_contains_ignore_case claims two implementations fold non-ASCII identically. They do not, and the difference falls on the Bash 3.0 path, which CI runs against GNU tr.
Current behavior
src/assert/core.sh:441-450 picks shopt -s nocasematch on Bash 3.1 and above, and falls back to two tr '[:upper:]' '[:lower:]' pipelines below that (:498-499). The comment at :461-466 says the two agree on non-ASCII in a UTF-8 locale.
Measured: BSD tr on macOS folds ÑÜ. GNU tr and busybox tr do not. ${v,,} folds under C.UTF-8 but not under C.
The tr branch is the Bash 3.0 path. The Bash 3.0 CI job runs on Debian, so it uses GNU tr. assert_contains_ignore_case "ñ" "Ñ" therefore behaves differently there than on a developer's Mac, and the comment says it should not.
Expected behavior
Fix the comment to state what happens, and decide what the assertion promises. Either document it as ASCII-only case folding, or make the two branches agree on the domain it claims to cover.
Worth noting the wider point, since the same trap will come up again: tr is not a fixed implementation. Any claim that a pure-Bash construct and an external tool agree needs testing against BSD, GNU and busybox, not only the developer's platform. .claude/rules/perf-fork-budget.md already records two silent version traps of this family (the & replacement on 5.2, the # pattern on 3.0); this is a third, across tr implementations rather than Bash versions.
Found while measuring version-gated alternatives to forking helpers.
Summary
A comment in
assert_contains_ignore_caseclaims two implementations fold non-ASCII identically. They do not, and the difference falls on the Bash 3.0 path, which CI runs against GNUtr.Current behavior
src/assert/core.sh:441-450picksshopt -s nocasematchon Bash 3.1 and above, and falls back to twotr '[:upper:]' '[:lower:]'pipelines below that (:498-499). The comment at:461-466says the two agree on non-ASCII in a UTF-8 locale.Measured: BSD
tron macOS foldsÑÜ. GNUtrand busyboxtrdo not.${v,,}folds underC.UTF-8but not underC.The
trbranch is the Bash 3.0 path. The Bash 3.0 CI job runs on Debian, so it uses GNUtr.assert_contains_ignore_case "ñ" "Ñ"therefore behaves differently there than on a developer's Mac, and the comment says it should not.Expected behavior
Fix the comment to state what happens, and decide what the assertion promises. Either document it as ASCII-only case folding, or make the two branches agree on the domain it claims to cover.
Worth noting the wider point, since the same trap will come up again:
tris not a fixed implementation. Any claim that a pure-Bash construct and an external tool agree needs testing against BSD, GNU and busybox, not only the developer's platform..claude/rules/perf-fork-budget.mdalready records two silent version traps of this family (the&replacement on 5.2, the#pattern on 3.0); this is a third, acrosstrimplementations rather than Bash versions.Found while measuring version-gated alternatives to forking helpers.