Repository navigation
fix(interpreter): ${#v} counts bytes under the C locale - #2627
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | e68f9f4 | Commit Preview URL Branch Preview URL |
Oct 08 2026, 03:00 AM |
chaliy
force-pushed
the
claude/c-locale-length
branch
from
October 8, 2026 02:14
06ac3fc to
7eac9dd
Compare
LC_ALL, LC_CTYPE, LANG (first non-empty) set to C or POSIX make ${#v}
count bytes like bash. ${#v} inside a ${x:-...} operand counted bytes in
every locale and now counts characters.
chaliy
force-pushed
the
claude/c-locale-length
branch
from
October 8, 2026 02:59
7eac9dd to
e68f9f4
Compare
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.
Requested by Михайло · project thread
What changed
${#v}counts bytes when the shell's locale is C or POSIX, read fromLC_ALL, thenLC_CTYPE, thenLANG(first non-empty), as bash does.local LC_ALL=...scopes it like any variable.${#v}inside a default operand (${x:-${#s}}) counted bytes in every locale; it now counts characters like the top-level form.Why
Bash-oracle gap
unicode-and-bytes. Agent scripts setLC_ALL=Cfor fastsort/grepand then size strings; bashkit reported characters where bash reports bytes.Before / After
New spec
c-locale-length.test.sh(5 cases, checked against bash 5.2 and bybash_comparison_tests).Risk
Low. With no locale variable set bashkit stays UTF-8 (bash would fall back to C). Slices, case changes and globs stay character-based under C because shell words cannot hold a split UTF-8 sequence; documented in limitations ("Locale").
Checklist
-D warningsbash_comparison_testsGenerated by Claude Code