Repository navigation
executor: port line_number_for_err_trap for ERR-trap LINENO (Refs #3553) - #3602
Merged
Merged
Conversation
…3553)
GNU keeps a second line tracker, line_number_for_err_trap
(execute_cmd.c:291), written only by SET_LINE_NUMBER (skipped while the
ERR trap is in progress) at the leaf stamp sites — simple :936,
subshell :696, arith :3904, cond :4138 — and by the ambient pins at
pipeline :2895 and the misc-compound frame :1141. The :854-883
redirect-failure arm binds that tracker into line_number for
run_error_trap, so a compound's OWN redirect failure reports the last
stamped line, not the compound's: `{ :; } </bad` names the previous
leaf, arith/cond name the ambient line, and inside a function the
failing call reports the CALL line because execute_function
unwind-protects the tracker (execute_cmd.c:5242).
Mirror it with err_trap_line, stamped in set_current_line before the
ambient env write: leaf kinds stamp their own line, pipeline and the
arith/cond/function_def frame pin to the last stamped line
(__RUBASH_CURRENT_LINE before this command's stamp); arith and cond
also stamp their own line once their own redirections have bound
(:3904/:4138), and execute_function saves/restores the tracker across
the call (:5242). The consumed value replaces command.line in the ERR
action's $LINENO pin (execute_cmd.c:873).
Also close the double fire the issue's matrix exposed: the #2659
marked-redirect-failure conversion already promised the
fired-at-dispatch record in its comment but never set it, so the list
loop's own adjudication look ran the trap again for `[[ x = x ]] </bad`;
set err_trap_fired_at_dispatch after the conversion fire.
Pins: tests/issue3553_err_trap_lineno.rs — previous-leaf reporting,
the full compound matrix, the cond single-fire, and the
function-frame restore — all byte-identical to vendored GNU 5.3.20;
neighboring trap/LINENO suites (2659/720/846/2117/1162-1166/1171/
1661/2202/2332/2281/1720) stay green.
Refs #3553
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
F 点:无 未跑/VOID 的腿:本地全量 lib 与 -D warnings 未跑(以 CI head 腿红集 + 编译/钉跑通代替判读)。 |
Member
Author
|
【队长终裁】PASS 核过审计报告(6886872456)+ CI 全表。钉 4/4,fail-first 0/4(全红,症状与 issue 完全一致:base 报复合自身行, |
caomengxuan666
marked this pull request as ready for review
November 15, 2026 02:05
This was referenced Nov 15, 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
Ports GNU's line_number_for_err_trap (execute_cmd.c:291): a second line tracker written only by SET_LINE_NUMBER sites — leaf stamps (simple :936, subshell :696, arith :3904, cond :4138) and the ambient pins (pipeline :2895, misc-compound frame :1141) — so a compound command's OWN redirect failure (execute_cmd.c:854-883) reports the last stamped line instead of the compound's.
Pins: tests/issue3553_err_trap_lineno.rs — previous-leaf reporting, the full compound matrix, the cond single-fire, and the function-frame restore — all byte-identical to vendored GNU 5.3.20; neighboring trap/LINENO suites stay green.
Refs #3553