Repository navigation
fix(executor): feed ( of $( to the case-word tracker in comsub walkers (Refs #3605) - #3696
Merged
Merged
Conversation
…lkers (Refs #3605) run-comsub-posix class D. Every `$(` arm that consumed the `(` inline skipped it for the `case WORD in` tracker too, so `word_boundary` stayed false after `$(` and `case` right at a nested substitution's start never armed the tracker. The pattern `)` then decremented paren depth: `$(echo $(case w in e) echo l;; esac)` truncated the outer span at `esac)` (the inner substitution's own closer), the body tokenized unclosed, and the driver reported `unexpected EOF while looking for matching ')'`. GNU treats `(` as a reserved-word-permitting separator (special_case_tokens, parse.y:3369-3386) and reads the comsub body as fresh input in parse_comsub (parse.y:4451), so `$(case` is a command-position keyword. Feed the skipped `(` through the tracker (and update prev_sig) in the four walkers that consume it inline: substitution_metadata.rs scan_substitution_spans, lexer/quotes.rs copy_dollar_paren_body_raw[_cursor], command_prepare.rs copy_comsub_body_verbatim_for_ifs_marking. The sibling nested-case arms (nested_case_subst) already cover the `$(` inside a case context; parser dollar_command_substitution feeds every `(` to the tracker and was never affected. Verified vs GNU bash 5.3.20 (macOS, script files): the cv6-cv11 / cvnest matrix is byte-identical — `$(echo $(case w in e) x;; esac))`, `$(echo $(case $(w) in e) x;; esac))`, top-level and mixed-assignment shapes. New tests/issue3605_nested_case_comsub_spans.rs pins four. Remaining run-comsub-posix diff is the previously flagged error-reprint family (`: $(case ...)` reprint shape + case: progname/line-number format) — separate root cause, tracked on the issue. alias_helpers::copy_dollar_paren_body keeps the naive counter (alias-value text only); flagged in the same comment. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
caomengxuan666
marked this pull request as ready for review
November 16, 2026 09:40
Member
Author
|
【WIN-AGENT-AUDIT】PR #3696 第1轮 — 建议:PASS(已合并 squash d3f1cce) head(合并时): a7c5f6b base(merge-base): 96802ca 文件: 6 个 +293/-11 机制核查:
腿(逐项):
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
Refs #3605 (macOS gate class D,
run-comsub-posix).Every
$(arm that consumed the(inline skipped it for thecase WORD intracker too, soword_boundarystayed false after$(and acaseright at a nested substitution's start never armed the tracker. The pattern)then decremented paren depth:$(echo $(case w in e) echo l;; esac)truncated the outer span atesac)— the inner substitution's own closer — the body tokenized unclosed, and the driver reportedunexpected EOF while looking for matching ')'.GNU treats
(as a reserved-word-permitting separator (special_case_tokens,parse.y:3369-3386) and reads the comsub body as fresh input inparse_comsub(parse.y:4451), so$(caseis a command-position keyword.(through the tracker (and updateprev_sig) in the four walkers that consume it inline:src/executor/substitution_metadata.rsscan_substitution_spanssrc/lexer/quotes.rscopy_dollar_paren_body_raw/copy_dollar_paren_body_raw_cursorsrc/executor/command_prepare.rscopy_comsub_body_verbatim_for_ifs_markingnested_case_substarms (the$(-inside-case-context direction) and the')' if !single && !doublecase-skip arm incollect_command_substitution_source_exride along — same class-D subsystem.parser/command_substitution.rsdollar_command_substitutionfeeds every(to the tracker and was never affected.Verified (macOS, GNU bash 5.3.20)
$(echo $(case w in e) x;; esac)),$(echo $(case $(w) in e) x;; esac)), top-levelx=$(case w in e) x;; esac), mixed assignmentv=$(a=$(case $(w) in e) echo k;; esac); echo "$a").run-comsub-posix: the$(casetruncation class is gone; remaining diff is the previously flagged error-reprint family (: $(case ...)reprint shape +case:/syntax-error:progname + line-number format) — separate root cause.tests/issue3605_nested_case_comsub_spans.rspins four shapes (nested case, nested$(subject), top-level, mixed-assignment).Flagged sibling
src/executor/alias_helpers.rs::copy_dollar_paren_bodykeeps the naive paren counter — reachable only through alias-value text containing$(case; noted on the issue for a follow-up.