Repository navigation
fix(builtins): read -d multibyte delimiter matches only its word byte - #3958
Merged
Merged
Conversation
… (Refs #3943) GNU read.def:385+834 compares stream unit-start bytes against the -d WORD's first byte only — a typed delimiter eth (word bytes C3 B0) keys on 0xC3 and reads through every 0xF0, emoji lead bytes included; a lone 0xE9 with -d é never terminates. Rubash's text-domain faces kept two codepoint-keyed derivations: the inherited-stdin unit walker matched the delimiter char truncated to a byte (emoji U+1F600 lead 0xF0 == codepoint 0xF0 of ð cut the record; lone 0xE9/0xFF/0x80 stopped on every serve), and the text-domain single-byte marker form encoded the codepoint — so a serve whose scan had already read through the raw byte still cut the record at the trim layer (`read -d é -n 5` on ab\351cd served 61 62 instead of 61 62 e9 63 64). Every text-domain delimiter face now keys on the -d word's first byte (Executor::read_delim_word_byte, threaded through the free-fn scan chains): stdin_unit_is_delimiter/delimiter_byte_matches match exactly that byte, read_delimiter_single_form encodes it, and scan_text_record_bytes / joined_delimiter_scan_applies derive their delim from it. Callers without the word keep the legacy derivation. The byte-locale and proper-character controls keep byte-for-byte GNU shape. Pins: tests/issue3943_read_d_raw_byte_overmatch.rs (fail-first verified: 5/8 red at 9c520c3, green with the fix). Seed R136-B 12/12 under WSL GNU bash 5.3.20 vs the Linux rubash build. Oracle citations: read.def:385, read.def:834, read_mbchar delim_ind pushback (read.def:1193).
caomengxuan666
force-pushed
the
fix/3943-read-d-raw-byte-overmatch
branch
from
November 19, 2026 16:03
740442b to
7f7745a
Compare
The full-suite census runs test stems in parallel processes sharing the repo cwd: the pins' relative 'f' operands collided with other stems' files mid-run (CI census 71 vs 62 baseline failures — every extra failure was one of these pins reading another test's bytes). Rubash's own behavior was never wrong: the same scripts pass standalone and the seeds pass 12/12 on the Linux build. issue3944 and issue3945 pins carry the same latent hazard and are scoped the same way (their merged-face fixup rides the next tests-only PR).
caomengxuan666
force-pushed
the
fix/3943-read-d-raw-byte-overmatch
branch
from
November 19, 2026 16:37
3c44e98 to
95ed800
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.
Closes #3943.
GNU contract
read.def:385+834: the delimiter is the
-dWORD's first byte, compared against stream unit-start bytes. Delimiter eth U+00F0 (word bytes C3 B0) keys on 0xC3 — never on the codepoint 0xF0. A lone 0xE9 with-d énever terminates; an emoji (lead byte 0xF0) is read straight through.Root cause (two codepoint-keyed faces)
delimiter_byte_matcheshad abyte == delimiter as u8arm — the char's codepoint truncated to a byte. Emoji lead 0xF0 == codepoint of ð cut the record; lone 0xE9/0xFF/0x80 stopped on every serve.read_delimiter_single_form) encoded the codepoint byte: after [bug]read -dwith a single-byte delimiter >= 0x80 fails on file-backed input under a UTF-8 locale #3944 taught the byte scanners the word byte, a serve whose scan already read through the raw byte was still cut at the TRIM layer (read -d é -n 5onab\351cdserved61 62instead of61 62 e9 63 64).Fix
Every text-domain delimiter face keys on the word's first byte (
Executor::read_delim_word_bytefrom #3944, threaded through the free-fn scan chains): unit matching is exact, the single form encodes the word byte,scan_text_record_bytes/joined_delimiter_scan_appliesderive from it. Callers without the word keep the legacy derivation.Verification
tests/issue3943_read_d_raw_byte_overmatch.rs: fail-first verified — 5/8 red at 9c520c3 (post-[bug]read -dwith a single-byte delimiter >= 0x80 fails on file-backed input under a UTF-8 locale #3944 master), green with the fix.read -dwith a single-byte delimiter >= 0x80 fails on file-backed input under a UTF-8 locale #3944/[bug]read -t 0returns success when no input is available #3945 pins green.