Skip to content

assert_contains_ignore_case: the non-ASCII folding comment is wrong for GNU tr #1351

Description

@Chemaclass
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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions