Repository navigation
fix(#551): C-family message formats - EOF naming, [[ =~ two-part diagnostic, single-cut stdin line numbers, write-error prefix - #563
Merged
Conversation
…gle-diagnostic cuts, stdin line offsets, write-error prefix
Cell-by-cell against WSL GNU 5.3.0 (stdin oracle, 2026-10-12):
C1 (line numbers): the read-stage EOF diagnostics numbered lines inside
the gathered group text; the prefix is global, so a stdin group after
the first reported group-local N (echo A / echo B / echo "unclosed said
line 1, GNU line 3). Shift open/eof/heredoc lines by the group's base
offset at every script_driver print site (parser-stage errors were
already token-shifted).
C3a: echo ${a[ named ] because the unclosed-subscript walk let ${ flip
command position; the braced parameter is word material (parse.y:5513
P_FIRSTCLOSE|P_DOLBRACE) and a [ not directly preceded by $ never opens
a subscript (parse.y:4126 LEX_WASDOL) - GNU names }. The walk now
consumes the braced body via the dolbrace scanner and bails to the
generic close-char scan when it never closes.
C3b: ${ inside $(( never pushed a pair in GNU (parse.y:4126-4136
P_ARITH peek FUNSUB_CHAR) - $((1+${${x names the arith ). Both
close-char scans now skip the ${ push under an arith pair.
C4a/c: [[ a =~ (b ]] - under PST_REGEXP the regex word's ( opens
parse_matched_pair whose EOF reports ) at the ( line and sets
PST_NOERROR (parse.y:3914), so yyerror's tail is suppressed
(parse.y:6724-6726) and the rhs rejection "unexpected argument to
conditional binary operator" (parse.y:5227, EOF line) is last. The cond
classifier now emits the two-line bare shape for an unclosed unescaped
( in the =~ rhs.
C4b: [ ( 1 -eq 1 - read_token's ( after a WORD token is the
function-def ( (parse.y:3774-3790 keeps PST_SUBSHELL off); the
close-char scans' word machines now track every word character so a
following ( is not a subshell continuation - GNU rejects the next token
("near unexpected token `1'" + verbatim echo at line 1).
C5: the prefix cut used the INNERMOST construct's line, re-running text
GNU considers part of the failed parse (echo one / echo ${x / "<x
printed two diagnostics; GNU one, the quote's, at line 3).
unclosed_input_close_char_posix now returns the OUTERMOST construct's
line for the cut plus an any-open-array-list rc family flag (v=(<(echo
still exits 1).
C6: a word-attached <( / >( body is parse_comsub (parse.y:5494-5524
read_token_word shellexp) - EOF takes the yyerror route: matching )' at
the EOF line (v=(<(echo: line 2, not the array's open line 1).
C8: exec 3< f; echo x >&3 printed "3: Bad file descriptor" because the
dup arm conflated open-but-read-only with closed. dup2 of any open fd
succeeds (redir.c:1153); the write fails at sh_chkwrite
(builtins/common.c:320) - "echo: write error: Bad file descriptor",
rc 1, one wording for echo/printf with or without the trailing newline
(huck#186/#190). A closed fd still fails at setup ("3: Bad file
descriptor").
C1/C2/C7 verified already-green on master: all 11 stdin line-N cells,
the verbatim echo cells, and the uniform builtin prefix (argv0: line N:)
probe byte-equal.
Incremental twins mirrored: the close-char residual scan (both `${`
arms and the word machine) and the subscript residual scan (the `${`
consume-or-park arm) stay oracle-equal — the randomized
incremental/full batteries cover the seam (an unterminated braced body
parks at the `${` like the S1/S2 re-derivation points).
GNU anchors: parse.y:3901-3915, 4126-4136, 4467, 5169, 5223-5227,
5443-5460, 5494-5524, 5513, 6724-6726, 6814; redir.c:1153;
builtins/common.c:320-334. Tests tests/issue551_message_format_family.rs
(stdin-driver byte assertions, exe path normalized to bash like the
audit baseline sed).
This was referenced Oct 12, 2026
caomengxuan666
added a commit
that referenced
this pull request
Oct 12, 2026
Conflict resolution, src/parser/token_actions.rs: the #563 C4b tuple classifier and the #565 empty-fnhead newline naming are two cells of the same '(' error classifier — master's explicit None/Eof arms already implement the #565 cells, so the merged block keeps master's tuple structure and carries the #565 rationale comment on the arms that implement it. C4b acceptance (tests/issue516, 7/7) and the #565 matrix (6/6) both pass. Semantic reconciliation, tests/issue565...: the x=1 ( cell followed the pre-#516 #452 join-and-EOF adjudication; master's #516 re-adjudication (token error at the paren, GNU p14/p16/p21 + q-series) supersedes it per the suite-parity rule — the cell now expects the trunk outcome. Full suite parity vs fresh master @ 32f9260: 43 failed on both sides, name-identical in both directions; branch additionally passes the 24 new #564/#565/#566 regression tests.
caomengxuan666
added a commit
that referenced
this pull request
Oct 13, 2026
…are drive-root POSIX form (#564 #565 #566) (#577) * fix: Wave4c batch - operator-position procsub line joins, empty fnhead newline naming, bare drive root cd (#564/#565/#566) #564: GNU read_token (parse.y:3776-3796) declines the `<'/`>' operator when peek_char == '(' and falls into read_token_word, whose shellexp arm (parse.y:5494-5524) reads the `(...)` body via parse_comsub (parse.y:4451) across physical newlines - ONE word token regardless of what precedes the introducer. rubash's group reader committed the logical line after the introducer line, so `cat <(echo' NL `echo hi' NL `)' died with `syntax error near unexpected token `(''. Three pieces: the one-shot unclosed-input oracle (continuation.rs) and the incremental close-char residual scanner now push the body's `)' matched pair when an ADJACENT `(' follows the redirect operator (the K5 tail park covers the buffer edge), the join gate extends to operator-position bodies via the text-level oracle line_ends_in_open_operator_process_substitution (the exact complement of the #463 word-attached gate), and the procsub source reconstruction folds only STRAY joined newlines back to `\n' (leading, or doubled after `;'/`;;' - positions where a reconstructed `;' is a syntax error a newline never is) while mid-body and trailing separators keep the `;' spelling the #373/#381/#390 adjudication pins (`case esac in ; esac', `echo bye ;'). Acceptance: WSL GNU 5.3.0 `cat <(echo hi\necho hi2\n)' runs BOTH lines and the script continues, `echo <(echo\necho hi2\n)' still evaluates to /dev/fd/N; 11 new tests green, 4 RED on fresh master d116874. #565: the shifted `(' of the function_def production (parse.y:1054 via read_token's parse.y:3774-3790 classification) is the token stream's LAST token for a final line without a terminator. GNU's reader still hands yacc the physical line's NEWLINE and rejects THAT: `syntax error near unexpected token `newline'' + print_offending_line of the `(' line (parse.y:6814; WSL GNU probes: `[ (` NL, `f (` NL, `echo (` NL and `bash -c '[ ('` all name `newline', never `('). The name_override arm now maps that nothing-after-the-shifted-paren shape to `newline' without touching the #563 C4b neighbours (two+ words still name the `(' itself). `x=1 (' is pinned as the #452 adjudication boundary, NOT a GNU cell: rubash accepts assignment-prefix + subshell (real GNU 5.3.0 rejects even the raw corpus shapes), so the reader's join stands and clean EOF reports the `unexpected end of file from `(' command' diagnostic at the EOF line. Harness: the stdin driver binds argv[0] as the diagnostic program name, so the file normalizes the exe path to `bash' like the #551 harness. 9 tests green, 4 RED on fresh master. #566: boundary contract B1 (docs/windows-path-contract.md L1) accepts the drive-form operands `/c/...', `/c/', `/c/.', `/D' - but the BARE root `/c' slipped past shell_path_to_windows_inner's drive arm (len >= 3 with a slash at byte 2) into the shell-root mapping, where map_logical_path resolved it to <root>/c -> ENOENT: `cd /c' failed while `cd /c/' worked, and a root carrying a `d/' directory made `cd /d' work by coincidence. The drive arm now maps the bare root to the drive root (case-insensitive) and map_logical_path's drive-form exclusion covers the two-letter spelling; `cd /c' renders the POSIX `/c/' exactly like its slashed sibling, and a same-named root child no longer shadows the drive. Contract doc ledger and the suite's "filed separately" note updated. 7 tests green, 5 RED on fresh master. * fix(executor): discard the FatalNounset heredoc-expansion verdict explicitly command_prepare.rs's function-call redirect gate calls finish_heredoc_expansion_error for its exit-code store and drops the run/continue verdict (shape carried over the 32f9260 base on both sides, unchanged by the #573 merge). The bare call trips unused_must_use once the crate builds under RUSTFLAGS=-D warnings; make the discard explicit. No behavior change.
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 #551。
审计基线 764b9dd 的 C 组(消息格式族)逐格对齐 GNU bash 5.3.0(WSL stdin 法 oracle)。本分支基于 rebase 时的 origin/master(eb062957)。逐格验收全部字节级归零(stderr + rc,rubash argv0 按 audit 基线 sed 归一为
bash后比对;探针 41 格双侧 diff = 0)。范围声明对齐 #551:只收纯格式/诊断形态分歧;rc 级项(#508/#542/#510)与内部字节泄漏族(#517/#518/#548)不动。GNU 规范坐标全部引用
third_party/bash(parse.y/redir.c/builtins/common.c),无 GPL 代码片段复制,注释只写行为事实 + 坐标。C1 · stdin/管道驱动 line N(11 格)— 已绿 8 格 + 本分支补行号偏移
764b9dd→eb062957 期间 master 已带上
line N:(8 格探针 byte-equal:#211/#385/#574/#592/#617/#621/#625/#656,回显亦逐字)。本分支修掉残留的行号取点:printf 'echo A\necho B\necho "unclosed' | shellbash: line 3: unexpected EOF while looking for matching '"'bash: line 1: …(组内局部行号,漏加 line_offset)bash: line 3: …✅根因:read-stage EOF 诊断在 gather 组文本内取行,前缀是全局行;第二组起全部偏小。修复:
script_driver.rs五个读期打印点统一加组基偏移(parser 期错误本就走 token 位移,不受影响)。heredoc 警告行号同步。C2 · 回显行逐字(3 格)— 已绿
#211/#575/#284:master 已逐字回显(
echo L2;;→`echo L2;;'),探针 byte-equal,本分支无改动,测试锁定。C3 · EOF 命名(2 格)
echo ${a[…matching}'`]}✅echo $((1+${${x…matching)'`})✅规范:
${走 parse_matched_pair(P_FIRSTCLOSE|P_DOLBRACE)(parse.y:5513),内部非$前缀的[是普通字(parse.y:4126 LEX_WASDOL)→}赢;$((的 P_ARITH 扫描里非 funsub${是普通算术文本(parse.y:4126-4136 peek FUNSUB_CHAR)→)赢。修复:下标 walk 用 dolbrace 扫描器消费${…}体(未闭则让位给通用 close-char 扫描);两份 close-char 扫描在算术对内跳过非 funsub${的压栈。孪生(增量)扫描同步镜像,randomized battery 覆盖接缝。C4 ·
[[ ]]/[消息形态(3 格)[[ a =~ (b ]]line 1: unexpected EOF while looking for matching ')'+line 2: unexpected argument to conditional binary operator(无尾部无回显)looking for ']]'+from [[ command[[ x =~ (unclosed[ ( 1 -eq 1line 1: syntax error near unexpected token1'+ ``[ ( 1 -eq 1' ``line 2: unexpected end of file from '(' command on line 1规范:PST_REGEXP(parse.y:5169,仅
=~)下 regex 词内未转义(走 parse_matched_pair,其 EOF 报)(start_lineno)并置 PST_NOERROR(parse.y:3914),yyerror 尾部被抑制(parse.y:6724-6726),cond 的 rhs 拒绝(parse.y:5227,EOF 行)是最后一条 → 新barespec 形态。(紧跟 WORD 是函数定义括号(parse.y:3774-3790 不置 PST_SUBSHELL)→ 扫描词机现在记录全部词字符,(后不再当子 shell 续读,交给解析器在下一 token 报错 + 逐字回显。C5 · 双重诊断(1 格)
echo one+echo ${x+"<xline 3: …matching '"'}+",行号错)规范:引号开在
${扫描内,quote 递归的 EOF 报引号自身行(start_lineno)且 PST_NOERROR(parse.y:3914)抑制一切后续报告。修复:prefix 切割改用最外层未闭构造的行(unclosed_input_close_char_posix返回结构体,新增outermost_line),失败组内文本不再重跑。C6 · 行号取点(1 格)
v=(<(echoline 2: …matching ')'(EOF 行,rc 1)line 1(数组开行)line 2,rc 1 ✅v=(<(echo+echo xline 3line 2line 3✅规范:词附
<(/>(体走 parse_comsub(parse.y:5494-5524 shellexp),EOF 是 yyerror 路由 → EOF 行 + "matching)'"。v=(a` 纯数组仍报开行 rc 1(#633 矩阵不受扰)。C7 · 内建前缀统一 — 已绿(化妆品格)
#406/#204/#792:master 上四组探针(
kill ""/kill %/readonly unset/nameref 自引用)前缀全部统一为{argv0}: line N:,同脚本无混用,byte-equal。无改动,测试锁定。C8 · write error 前缀(2 格)
exec 3< f; echo x >&3bash: line N: echo: write error: Bad file descriptor(rc 1)bash: line N: 3: Bad file descriptorprintf "abc" >&3(无尾随换行)printf: write error: …(rc 1)3: Bad file descriptor(rc 0)printf: write error: …rc 1 ✅exec 3>&-后 dup 关闭 fd3: Bad file descriptor规范:对任何打开着的 fd,dup2 成功(redir.c:1153);写在 sh_chkwrite(builtins/common.c:320-334)失败 →
<builtin>: write error: <strerror>。修复:dup 臂区分「打开但只读」(放行,写失败走既有write_bad_output_fd_diagnostic单一措辞出口 → #190 的换行漂移三形态收敛为一)与「真关闭」(保持 setup 期N: Bad file descriptor,cli_tests 既有断言不动)。验证
tests/issue551_message_format_family.rs(新,9 测试):stdin 驱动字节级断言,覆盖 C1 行号偏移 / C3 命名矩阵 / C4 两段式 / C5 单诊断 / C6 EOF 行 / C8 三段 + 关闭 fd 对照 + funsub/dparen 邻域守卫(含((1+2rc 2 家族)。cargo test --no-fail-fast:分支失败集 vs fresh master(eb062957)逐名双向 diff 均为空(55==55,master 既有红带——bashdb/examples/heredoc command_chaining 等——原样保留,不属本车道)。范围外记录(供后续开格)
echo <(echo(顶层未闭 procsub):GNU 跨行续读,rubash 立即near unexpected token '('——语义分歧,非消息格式,建议独立 issue。[ ((函数定义括号后直接换行/空体):GNU 报near unexpected token 'newline'/unexpected end of file,rubash 报near '('——同族相邻格,[meta] 诊断消息格式族 tracking(C1-C8,约 30 条):stdin line N 前缀缺失 / 回显行重排 / EOF 命名 / [[ ]] 消息形态 / 双重诊断 / 行号取点 / 程序名前缀混用 / write error 前缀 (P3) #551 C4 验收范围(639/716/688)已全绿,此为邻域残留。