Repository navigation
fix(eval): report EOF-close line with the same -1 eval mapping as open lines (Refs #3605) - #3674
Merged
Merged
Conversation
…n lines (Refs #3605) GNU yyerror (parse.y:6883-6891) reports line_number at EOF for a matched-pair construct (\'unexpected EOF while looking for matching `X\'\'), and inside eval the eval-string lines map to the caller's counter as caller_line + i - 1 (evalstring.c:345 line_number--, SEVAL_RESETLINE not set). The eval close-char path in execute_eval_source mapped the scan's eof_line (last content line + 1, a line index like open_line) as caller_line + eof_line — one past the line GNU reports — so exportfunc.tests:82's eval printed 'eval: line 84: unexpected EOF while looking for matching `}\'' where GNU prints 83. Map eof_line through the identical -1 index conversion the open_line arm and both sibling call sites (command_substitution.rs, command_input_scope.rs) already use. run-exportfunc now matches GNU byte-for-byte (macOS gate PASS). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿(逐项给数字与名字):
F 点:无。 未跑/VOID 的腿:无。 |
This was referenced Nov 16, 2026
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.
Summary
run-exportfunc(exportfunc.tests:82):eval 'foo() { _; } >_[${ $() }] ;{ echo eval ok; }'printedeval: line 84: unexpected EOF while looking for matching \}'where GNU printseval: line 83`.GNU reports
line_numberat EOF for a matched-pair construct (yyerror EOF branch,parse.y:6883-6891), and insideevalthe string's lines continue the caller's counter ascaller_line + i - 1(evalstring.c:345line_number--—SEVAL_RESETLINEis not set for eval). rubash's eval close-char path mapped the scan'seof_line(last content line + 1 — a line index likeopen_line) ascaller_line + eof_line, i.e. one past the line GNU reports. This applies the identical-1index conversion theopen_linearm and both sibling call sites (command_substitution.rs,command_input_scope.rs) already use.Refs #3605 (class B, run-exportfunc — clears the suite's only real diff; the
cannot execute binary filenoise belongs to #3586).GNU anchors
parse.y:6883-6891— yyerror EOF branch reportsline_numberat EOF.builtins/evalstring.c:345—line_number--underpush_stream(lreset=0): eval-string lineisits atcaller_line + i - 1, EOF atcaller_line + lines.builtins/eval.def—evalpassesSEVAL_NOHIST|SEVAL_NOOPTIMIZE(noSEVAL_RESETLINE).Verification (macOS arm64, GNU bash 5.3.20 oracle)
run-exportfunc→ PASS (zero diff).eval 'foo() { _; } >_[${ $() }] ;{ echo eval ok; }'(caller lines 1, 3, 82), multi-line eval strings,x=${a[1(}'close),x=$(echo foo,x=$((1+,x="foo,x=`echo, nestedevalinside eval.tests/issue3605_eval_eof_close_char_line.rs(3 tests) — the EOF mapping at caller line 1, scaled across a multi-line string, and the subscript}'variant.issue318_eval_eof_diagnostics,issue1609_eval_parse_diag_routing,issue2342_eval_arith_eof_line,issue2780_eval_arith_for_eof_line,issue3183_redirect_and_eof_lines— 46/46 green;cargo fmt --checkclean.Test plan
cargo test --test issue3605_eval_eof_close_char_linerun-exportfuncPASS