Skip to content

[cosmetic] 语法错误消息 token 回显保真:(( i=0; i<3 )) 空格规范化、缺 line N: 前缀、程序名形态不一(rc 一致) #522

Closed

Description

@caomengxuan666

退出语义一致(rc 均 2),仅消息文本分歧 → cosmetic。单独立 issue 以便与语义类修复解耦排期。

复现

for ((i=0; i<3)); do :; done     # F012
for()                             # F126(互见:命令位置 ( 的解析/诊断 issue)
stderr rc
GNU 5.3.0(F012) bash: line 1: syntax error: arithmetic expression required + bash: line 1: syntax error: `((i=0; i<3))' 2
rubash 764b9dd(F012) bash: syntax error: arithmetic expression required + bash: syntax error: `(( i=0; i<3 ))' 2

三处保真差异:① token 回显被规范化(((i=0; i<3)) → (( i=0; i<3 )),GNU 回显源码原文);② 缺 line N: 前缀(rubash 其他错误路径有);③ 此路径程序名显示为 bash:(其他路径显示可执行路径),两形态并存不一致。F126 的 for() 文案差异(GNU 两行含源行回显 vs rubash 单行 EOF 文案)归入命令位置 ( 的 issue,此处仅作交叉引用。

规范/源码依据

bash error.c 的 parser 错误回显当前输入行原文(不重排空格);行号前缀与程序名由统一的 error() 入口注入。

跨实现互证(huck)

huck#211 "Align top-level syntax-error diagnostics to bash's 3-shape model"、huck#625 "An unterminated for (( … )) header reports the last line and huck's generic wording"(均已修复)——诊断保真总纲与 for 头部文案,同族。

证据

  • 语料出处:arith_for_header_diff_check.sh:68(F012);parser_syntax_errors_diff_check.sh:51(F126)
  • 复核:764b9dde 仍复现;旧构建 41de831 行为一致

Activity

  1. added
    bug
    P3-low
    on Oct 12, 2026
  2. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by #569 (Wave3). Vendored-bash anchors and RED-then-GREEN regression evidence in the PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3-lowbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions