Skip to content

fix(parser): skip nested $() as a unit inside an open case body (Refs #3623) - #3626

Closed
caomengxuan666 wants to merge 1 commit into
masterfrom
fix/3623-case-subject-comsub
Closed

caomengxuan666 wants to merge 1 commit into
masterfrom
fix/3623-case-subject-comsub

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #3623.

dollar_command_substitution does not nest depth on (/) while a case is open, so case $(ls) in scanned the inner comsub inline: ls completed as the case subject and the inner ) hit the case-close arm, truncating the outer substitution at $(case $(ls (syntax error near unexpected token ')').

GNU parse.y:4451 parse_comsub parses every $( as a fresh parse, so the inner comsub is opaque to the outer case machine. This change skips a nested $(...) as a unit when case_depth > 0 (same shape as the existing double-quote nested-$( skip), leaving a non-empty word so the case subject still completes at the next boundary.

Verified byte-identical to GNU for the issue repro plus empty-esac and pattern-list variants; 4 new regression pins in tests/issue3623_case_subject_comsub_regressions.rs.

…3623)

dollar_command_substitution does not nest depth on (/) while a case is
open, so case $(ls) in scanned the inner comsub inline: ls completed as
the case subject and the inner ) hit the case-close arm, truncating the
outer substitution at '$(case $(ls'.

GNU parse.y:4451 parse_comsub parses every $( as a fresh parse, so the
inner comsub is opaque to the outer case machine. Skip a nested $(...)
as a unit when case_depth > 0 (same shape as the double-quote nested-$
skip), leaving a non-empty word so the case subject still completes at
the next boundary.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3626 第1轮 — 建议:FAIL
head: 1714d19 base(merge-base): 27e1d0d 文件: 2 个 +96/-0
关联 issue: #3623(状态:open,我核过的时间:2026-11-16 本地)

机制核查:

腿(逐项给数字与名字):

  • 钉自跑:cargo test --test issue3623_case_subject_comsub_regressions → 4 passed / 0 failed(single_command_comsub_in_case_subject_does_not_truncate / comsub_subject_with_empty_esac_stays_closed / comsub_subject_with_pattern_list_still_matches / case_without_inner_comsub_still_scans)。
  • fail-first:base 27e1d0d + 同一钉 → 复现缺陷那格红(single_command_comsub_in_case_subject_does_not_truncate 之前整脚本 rc=2,c3623c.sh 同形;钉在 base 上表现为失败)。缺陷面判别成立。
  • lib 双边:head 失败名集 {api::consumer_tests::issue2084_session_end_restores_host_process_state} / base 失败名集 {同左} / 差集 ∅。
  • -D warnings:本 PR 文件 0 新增。
  • 卫生:fmt rc=0(2 文件逐个);marker-lint OK;utf8 脚本不存在(VOID)。
  • CI:红任务 = Rust tests / Rust tests (macOS) / GNU regression goldens and canaries;红名 = api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell(基线 issue2875)+ issue2859_jobs_face_two_background_jobs_count(master-red,后续 ci: unmask master-red — issue2875 out/ resolver + masked test/corpus fixes #3750 批次)。新钉不在 CI 执行集(CI 只跑 cargo test --lib)。
  • GNU 对照(WSL GNU bash 5.3.20,脚本 target/probes/c3623.sh / c3623c.sh / c3623d.sh / c3623e.sh):14 形单行矩阵 + 6 形 case-subject 多行矩阵 + 缺陷 repro 全部 GNU 正确;head 在缺陷 repro 上修好,但在 F1 形状上回归。

F 点(建议 FAIL):

未跑/VOID 的腿:

  • 无(钉在本平台可执行)。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3626 第2轮 — 建议:FAIL(维持 S8 裁定;建议以 #3627 为准关闭本 PR,待队长裁定)
head: 1714d193235c103ffa3697a03df2c2d3549cc98a(自 S8 未变)base(merge-base): 27e1d0d29fb9aab5b02627816c21f8dcc94942cf
关联 issue: #3623(open)

V 波收网复核:

@caomengxuan666

Copy link
Copy Markdown
Member Author

superseded — master 已修,保留 FAIL 判词

本 PR 的机制(case_depth > 0 时把嵌套 $(...) 当单元跳过)准入过宽,此前判 FAIL 成立;现在 master d3f1ccef4(#3696,Refs #3605)已用 nested_case_subst 深度实现了同一目标($( 的 ( 喂给 case-word tracker),且覆盖更精确。

GNU 5.3.20 证据(脚本文件,36 形):master 尖 f02d7299d 已与 GNU 逐字节一致,包括:

不关闭本 PR(按 lane 规则:#3627 未合入则不关、不修,保留 FAIL 判词);如需清理请由主持人裁决。

@caomengxuan666

Copy link
Copy Markdown
Member Author

superseded — 关闭(不合并)

与 #3627 同一裁定:#3623 的缺陷已由 master d3f1ccef4(#3696,Refs #3605)的 nested_case_subst 机制修复,本 PR 的 case_depth > 0 准入过宽(F1 单行 pattern 形回归)仍成立,保留 FAIL 判词。

lane o3 本轮实测(WSL GNU bash 5.3.20 脚本文件 / master 尖 f02d7299d 二进制):

#3605 / #2666 均为 umbrella,保持 OPEN;#3623 由队长按 master 证据另行关单。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] $(case $(cmd) in ...) nested single-command comsub in case subject truncates the outer substitution

1 participant