You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[cosmetic] for (( i="1;2" )) 算术错误回显泄漏原始控制字符 0x1c:i=\x1c1;2(GNU 逐字回显 i="1;2)(P3) #548
Activity
caomengxuan666 commentedon Oct 13, 2026
修复 PR:#584(已合入目标 base master,CI 全绿)
根因
不只是回显渲染问题——标记字节一路进入了求值输入。
src/parser/arithmetic_for.rs把三个 section 的求值文本建为 token.value 归一化 join,而带引号的 word 在 token value 里以载体协议传输("1;2"的值是\x1c1;2,0x1c = 引号胶水位标记,registry 见src/executor/markers.rs)。该字节既毒化算术求值器,也经ArithEvalError::render泄入 evalerror 回显。语义契约(vendored bash):
make_cmd.c:254-261(section 原文逐字,段首空白跳过、引号保留)+execute_cmd.c:3171(求值前引号剥离)。修法:section 求值输入改用逐字 capture(段首 trim、注册表码点在诊断边界剥离),求值器原地引号删除后自然复现 GNU 组合。字节级前后对比(WSL GNU bash 5.3.0 stdin oracle,
od -c)修复前(origin/master 7f18b44):
(
od -c实测两处034,即 0x1c)GNU bash 5.3.0 / 修复后(逐字节一致,含
i=1;2尾随空格与 token";2 ",原 issue 记录的"尾随空格微差"也随之消除):附带修复(同根因,超出 cosmetic 的实际语义病)
for (( i="3" ; i>0 ; i-- )); do echo hi; done:修复前整个循环被i=\x1c3: operand expected中止(0 输出);修复后与 GNU 一致输出hix3。验证
for (( i="a;b" ; 0 ; 1 ))(引号;不切节、到求值才报错,与 GNU 同形)、for (( 7++ ; ... ))、裸for (( i="1;2" ))解析错形态均 identical。tests/issue548_arith_for_carrier_echo_regressions.rs(0x1c/C0 载体字节不出现 + GNU 逐字 body 断言 + 成功路径)4 绿;全量RUST_TEST_THREADS=1 cargo test --no-fail-fast失败集与 origin/master 基线双向 comm:fix-only 为空(base-only 仅既有本地环境失败upstream_suite_slice_snapshots);RUSTFLAGS="-D warnings" cargo check、cargo fmt --check干净;PR CI 全绿。fix(parser): arithmetic-for sections evaluate the verbatim (( )) capt…