Repository navigation
fix(parser): case-clause first command takes the pattern line (Refs #3235) - #3614
Merged
Merged
Conversation
Fail-first: clause body's first redirect-first command must report the pattern line (GNU parse.y:5850-5851 plant, 810-811 capture), not its redirect target's end line. 15 cells, GNU 5.3.20-verified.
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
F 点:
处置:不合入、不关 #3235。建议作者把声称的 未跑/VOID 的腿:
|
…efs #3235) GNU parse.y reads each pattern word at command position (reserved_word_acceptable accepts the '\n' left by pattern_list's newline_list, parse.y:5900-5903), so read_token_word plants simplecmd_lineno with the pattern word's end line (parse.y:5850-5851). A redirection element captures the stamp only while it is unset (parse.y:810-811), so a clause body's first redirect-first simple command reports the pattern line, not its redirect target's end line. Track the last pattern-content token's end line per clause and run the #3209 restamp walk (restamp_function_body_first_command) over the parsed clause body: wrappers consume nothing, the first simple command ends the plant, nested case/function commands block it.
Member
Author
|
【WIN-AGENT-AUDIT】PR #3614 第2轮 — 建议:PASS(续作完成:补上正文声称的产品修法 commit) 机制核查:
腿(逐项给数字与名字):
F 点(第 1 轮):
续作记录:
未跑/VOID 的腿:无。 |
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
Refs #3235 — case-clause stamp residual of #3209.
Root cause: the #3209 restamp walk stops at
case_commandby design, and nothing else restamps a clause body's first command. rubash therefore reports a redirect-first clause command at its redirect target's end line (line 4 in the issue probe), while GNU reports the pattern line (line 3).GNU anchor (bash 5.3, parse.y): the pattern word is read at command position — the pattern_list newline_list leaves last_read_token at '\n', which
reserved_word_acceptableaccepts (parse.y:5900-5903) — soread_token_wordplantssimplecmd_linenowith the pattern line (parse.y:5850-5851). A redirection element captures the stamp only when it is still unset (parse.y:810-811), so the clause body's first command keeps the pattern line even when its redirect target is split across lines; the command word after the target does not re-plant (WORD is not inreserved_word_acceptable's set), and the plant resets only when that first command completes (clean_simple_command, parse.y:838). Wrapper commands in between (groups, if/loop conditions,time,[[ ]]) consume nothing; a nested case re-plants from its own pattern.Fix (this PR, second commit): in
parse_case_command, restamp each clause body's first redirect-first simple command to its pattern token's line, reusing the #3209 walk shape (stop at nested function/case, descend through wrappers). Pins: tests/issue3235_case_clause_pattern_line_stamp.rs — 15 cells (12 pattern-line pins + 3 guards), all byte-verified against GNU Bash 5.3.20 script-file probes.Known residual (not pinned): a quoted-newline command word (
a) >x\\<newline>y $'a<newline>b') still reports the target end line — the executor text floor insimple_command_first_word_end_line(command_text.rs) takes the max of the restamped value and the first word's newline count. Fixing that floor touches src/executor/command_text.rs, which open PR #3602 is actively editing (same-file guard), so it is recorded in the lane REPORT instead.本 PR 删除了什么
无删除:只新增回归钉文件与 case 子句行戳对齐修法;未删除任何公开面、命令、选项或测试。
UNVERIFIED-BY-CAPTAIN