Repository navigation
fix(read): decode raw-byte marker pairs in interactive read -p prompt (Refs #2883) - #3001
Merged
Merged
Conversation
…2883) Fail-first on master fb96e74: the four ESC-rendering cells fail ($'...' argument, variable value, command substitution, -e editor repaint) — the prompt renders U+E000/U+E01C raw-byte marker pairs instead of the ESC byte. Two control cells (0x01 data byte, literal backslash-brackets) already pass. GNU: builtins/read.def:316 (prompt is the word-expanded argument), read.def:670-674 (verbatim stderr print), read.def:697 (edit_line hand-off). Seed: #2879 sweep PTY cell s4.
…ry (Refs #2883) Both read-prompt consumers in read_builtin.rs (the stderr print and the line editor's read_edit_prompt) used the raw expand_word result, so control bytes arrived as U+E000 marker pairs and rendered as pair glyphs. New Executor::expand_read_prompt funnels both sites through decode_prompt_transport — GNU builtins/read.def:316 (prompt is the word-expanded argument), :670-674 (verbatim stderr print), :697 (edit_line hand-off). Decode only, no strip: this channel has no template stage that manufactures prompt-ignore markers, so a literal 0x01/0x02 in the expanded word is prompt DATA GNU prints verbatim; the new pin cell proves a strip step eats it (the strip-then-decode mirror from the issue was tested and narrowed on this evidence). Pair-encoded 0x01/0x02 decode back to the same data bytes. Pins: 4 ESC cells red on base now green; adds pair-encoded-0x01 comsub cell; -e cell switched to paced PTY input (all-at-once writes race the REPL read-ahead — harness artifact, captain-verified paced probe completes the read). Test file also carries its rustfmt reflow.
caomengxuan666
marked this pull request as ready for review
November 7, 2026 18:54
caomengxuan666
added a commit
that referenced
this pull request
Nov 8, 2026
…2885) - markers.rs census: add EXACT entry for __RUBASH_CURRENT_FILE (new carrier from #3035/#3047, missing from the E8 census). - marker_registry_roundtrips: remove all four TYPED_DATA_EXCEPTIONS (E002 shapes 1-3 fixed by #2882/#3006; E316 shape 3 by #3016/#3041); the stem now asserts every shape round-trips. - marker-lint-allowlist: delete the two #2882 KNOWN BLIND SPOT entries (their own text said delete when #2882 lands), plus two entries made stale by master-side changes: set.rs ESC rendering entry (#3044 restructured the table) and command_prepare contains:QUOTED_NULL_MARKER (#3006 converted those consumers to E400-aware helpers). - marker_leak_golden_pty: un-ignore the read -p cell (#3001 landed the read -p decode). - marker_leak_golden: set-listing C0 scalar cell now expects the ansic-quoted GNU form (rubash#3017/#3044), byte-verified against GNU bash 5.3.20; the no-marker assertion is unchanged. Verified on the merged tree (merge bd87ed1 + this commit): lint OK (117 consts / 258 sites), registry 10/0, PTY 2/0, golden 20/0, lib 1200/0/4, -D warnings rc=0, hygiene/fmt/CR clean.
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.
Refs #2883
根因
Interactive
read -prenders its prompt argument's raw-byte marker pairs literally: a prompt containing ESC displaysEE 80 80 EE 80 9C(the U+E000/U+E01C pair glyphs) instead of the ESC byte. GNU emits the byte.The expanded prompt word carries control bytes as raw-byte marker pairs (transport encoding,
src/executor/markers.rs). PR #2878 added the post-expansion decode (decode_prompt_transport) at the three PS0/PS1/PS2/PS4 sites, but theread -pprompt travels a different display path — read builtin → stderr print (non-edit) / line editor (edit) — and both of its consumers insrc/executor/read_builtin.rsused the rawexpand_wordresult undecoded:eprint!afterread_prompt_should_display), andread_edit_prompt, consumed by the line-editor repaint insrc/executor/read_io.rs.GNU 锚点
builtins/read.def:316—prompt = list_optarg: the prompt is the word-expanded argument.builtins/read.def:670-674— non-edit path prints the expanded bytes verbatim:fprintf(stderr, "%s", prompt).builtins/read.def:697— edit path hands the same bytes toedit_line(prompt, …).read -p(\[in the prompt argument stays literal text — pinned as a control cell).修法
src/executor/read_builtin.rs新增Executor::expand_read_prompt,两个消费点统一改走它:expand_word之后接decode_prompt_transport,把 marker 对还原为真实字节。机制级单点收敛,不是逐症状补丁。一处按证据收窄:issue 建议的 strip-then-decode 全镜像经钉验证不成立——本通道没有制造 prompt-ignore 标记的模板阶段,展开词中的字面 0x01/0x02 只能是 prompt 数据(GNU
fprintf逐字节输出),strip 会把它吃掉(钉read_p_prompt_keeps_decoded_sx01_data_byte在 strip 版下实测变红、decode-only 下绿;GNU oracle 对字面与 comsub 两形态均确认输出真 0x01 字节)。故本 PR 只做 decode:issue 括注的目标(解码出的 0x01/0x02 数据存活)对字面与对编码两种形态都达成。钉(
tests/issue2883_read_prompt_carrier_regressions.rs,script(1)PTY、字节级断言):fb96e741):4 个 ESC 渲染格全红($'…' 参数 = sweep s4 形、变量值、comsub、-e 编辑器 repaint),typescript 实证 prompt 渲染为<A<U+E000><U+E01C>B>;RUSTFLAGS="-D warnings"rc=0;hygiene clean;rustfmt clean;本 PR 删除了什么
无删除。仅在 read builtin 的 prompt 展开点接入既有的
decode_prompt_transport,外加新增钉文件。未碰src/lexer/continuation.rs,未改docs/api-ledger.md,无新公开 API 面。UNVERIFIED-BY-CAPTAIN