Repository navigation
fix(parser): echo the source line after ! in reserved position (rubash#3647) - #3765
Conversation
…ash#3647) The bang-after-pipe arm in token_actions.rs hand-rolled a __RUBASH_PARSE_ERROR_NEAR__ node with the token and line but no __RUBASH_PARSE_SOURCE__ assignment, so the executor NEAR arm printed the diagnostic with no line to echo, while GNU echoes the offending source line. It was the only NEAR producer in src/parser without the source assignment; the fix attaches it via offending_line_text, mirroring the Pipe arm in the same function. No other error shape changes: EOF reports still echo nothing, and legal bang positions are untouched. Regression tests: tests/issue3647_bang_after_pipe_source_echo_regressions.rs (10 tests: seed, second-stage, bare, mid-pipeline and pipe-err bangs, multi-line offending-line-only, spacing/comment verbatim, script file, EOF no-echo guard, legal-bang guard). Also updates the stale bang_after_pipe_rejected expectation in tests/issue360_parser_overlax_regressions.rs to the fixed output.
|
Thanks for the PR — and for the thorough write-up with the GNU oracle matrix and the fail-first numbers. Per the owner's rule, external PRs are reviewed by the captain first, so this one is queued for captain review and CI is being watched. No merge and no requested changes from this first pass. First-pass read of the diff (3 files, +239/−1):
CI at the time of this check (runs 43816319393 / 43816319597): API ledger tripwire SUCCESS, Shell functionality tests SUCCESS; Rust tests, Compatibility CLI tests, goldens, cross-target checks and the Windows compile check still in progress. As the PR body itself notes, the new stem is not executed by CI's nextest table, so the 10/10 and fail-first 8/2 figures rest on the author's box run for now — the captain's re-run is the deciding evidence, not CI. Two points flagged for the captain's review (not blockers from this pass):
Collision check: no other open PR touches Thanks again — the captain will take it from here. |
|
【WIN-AGENT-AUDIT】PR #3765 第1轮 — 建议:PASS 机制核查:
腿:
F 点:无。 续作记录:无(本轮未动代码)。 未跑/VOID 的腿:无。 |
|
【WIN-AGENT-AUDIT】PR #3765 第2轮 — 建议:PASS(已合并 squash V 波收网复核:
|
Fixes #3647.
Summary
echo hi | ! trueprinted only the diagnostic; GNU also echoes the offending source line. This PR restores the echo for the!-in-reserved-position shape (rc stays 2):Root cause
The
!-after-pipe arm insrc/parser/token_actions.rs(parse.y:1408-1413, rubash#360) hand-rolled a__RUBASH_PARSE_ERROR_NEAR__node with the token + line but no__RUBASH_PARSE_SOURCE__assignment, so the executor's NEAR arm printed the diagnostic with no line to echo. A scan ofsrc/parser/*.rsshowed it was the only NEAR producer without the source assignment. The fix attaches it viaoffending_line_text, mirroring the Pipe arm in the same function (+14/-0 in that file). No other error shape changes: EOF reports still echo nothing, and legal!positions are untouched.GNU oracle (bash 5.2.21, Simular box)
Echo happens for every "near unexpected token" report and echoes the physical line verbatim (leading/trailing spaces and trailing comments survive); the echoed line is the one at the reported line number (multi-line input echoes line 2 only, after line 1 ran). "syntax error: unexpected end of file" and "unexpected EOF while looking for matching" reports echo nothing. Post-fix, an 18-case GNU-vs-rubash
-cmatrix matches byte-for-byte after program-name normalization (seed, second-stage / bare / mid-pipeline /|&bangs,| |,&& |,time { },>>|, multi-line, spacing, comment,echo hi; !,! ! true, unclosed backtick).Verification (box, baseline afd0778)
tests/issue3647_bang_after_pipe_source_echo_regressions.rs: 10/10 on the fixed tree; fail-first 8 failed / 2 passed on the unpatched tree (the 2 passes are the EOF no-echo guard and the legal-bang guard).cargo test --lib: 1249 passed, 0 failed (single-threaded).cargo fmt --checkandgit diff --checkclean.Pre-existing failures (not introduced here)
/dev/shm/.../rubash:or.../rulinevs the stalebash:/ bareline 1:the tests expect); message bodies — including echo lines — are byte-identical. This stale-bash:-prefix family predates [parser] syntax error after!in reserved position does not echo the source line #3647.coprocx3 +test_function_body_can_be_time_commandunwrapNonefrom the in-processparse()API. None of their inputs contains a!token, so the touched branch (gated ontoken.value == "!") is unreachable for them; the parse results are identical with/without this patch.bang_after_pipe_rejectedin issue360 now expects the echo line (it still fails locally on the pre-existing prefix only, like its two siblings).Out of scope (verified, not fixed)
if true; then: rubash reportssyntax error: unexpected end of file from 'if' command on line 1vs GNU's baresyntax error: unexpected end of file— confirmed present on the unpatched baseline, separate EOF-wording divergence.!-after-pipe arm; every other NEAR producer already echoed.CI caveat
As with the recent P3 PRs, the new regression suite's only execution evidence is the box run above: the Rust-tests job is fail-fast and the "Run all integration test stems" step is skipped once the lib step goes red on the known master flaky (issue2875), so CI never executes the new file. That structural gap is unchanged by this PR.