Skip to content

fix(parser): accept N>> append redirect with procsub target (Refs #3505) - #3519

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3505-numbered-append-redirect
Nov 14, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3505-numbered-append-redirect

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

fix(parser): accept N>> append redirect with procsub target (Refs #3505)

Root cause: collect_trailing_redirections (src/parser/redirections.rs)
handled the RedirectOut arm by trying both procsub-target helpers, but
the Append arm tried only the combined &>/&>> helper, which declines a
numbered target like "3>>". The generic target parser then refused the
">" and the parser broke with "syntax error near unexpected token
'3>>'", leaving the Append redirect unconsumed. The lexer already
emitted the correct Append("3>>") token and simple commands already
worked because assign_append_target tries
append_process_substitution_redirect_target; the trailing-redirection
collector was missing the same arm.

Fix: mirror redirect_assign.rs in the Append arm - try
append_process_substitution_redirect_target for numbered append
targets before falling back to the plain target parser.

GNU anchor: bash 5.3 parse.y:574 (append redirection grammar accepts
a word target incl. process substitution).

Regression pin: tests/issue3505_numbered_append_redirect_procsub.rs
(9 cells; verified on Linux: head 9/9, base fail-first on the numbered
append shapes, adjacent parser_redirection_tests 68/0).

本 PR 删除了什么:无删除(纯新增 arm + 新增钉子文件)。

Verification note: fix and pin were verified by the fix lane on the
Simular box (Linux) against base 5219be9; captain review of the
merged shape still applies before merge.

Root cause: collect_trailing_redirections (src/parser/redirections.rs)
handled the RedirectOut arm by trying both procsub-target helpers, but
the Append arm tried only the combined &>/&>> helper, which declines a
numbered target like "3>>". The generic target parser then refused the
">" and the parser broke with "syntax error near unexpected token
'3>>'", leaving the Append redirect unconsumed. The lexer already
emitted the correct Append("3>>") token and simple commands already
worked because assign_append_target tries
append_process_substitution_redirect_target; the trailing-redirection
collector was missing the same arm.

Fix: mirror redirect_assign.rs in the Append arm - try
append_process_substitution_redirect_target for numbered append
targets before falling back to the plain target parser.

GNU anchor: bash 5.3 parse.y:574 (append redirection grammar accepts
a word target incl. process substitution).

Regression pin: tests/issue3505_numbered_append_redirect_procsub.rs
(9 cells; verified on Linux: head 9/9, base fail-first on the numbered
append shapes, adjacent parser_redirection_tests 68/0).

本 PR 删除了什么:无删除(纯新增 arm + 新增钉子文件)。

Verification note: fix and pin were verified by the fix lane on the
Simular box (Linux) against base 5219be9; captain review of the
merged shape still applies before merge.
@caomengxuan666

Copy link
Copy Markdown
Member Author

队长复核 PASS

结论:合入。 Refs-only,合入后队长手关 #3505。

Diff(已核对原文,与盘上已核修法逐字节一致): 2 文件 +290/−0:src/parser/redirections.rs +28(新 Append intake arm,与 assign_append_target 逐行镜像,continuation.rs 未动)+ 钉 tests/issue3505_numbered_append_redirect_procsub.rs +262(blob sha256 8c44ab43… 与预登记值一致)。GNU 锚点 parse.y:574(NUMBER GREATER_GREATER WORD → r_appending_to)。

Linux 腿(~/workspace/review-3519/,日志已从盘核验,零 VOID):

  • L2 钉头 9/9;L3 基底 fail-first 4/9,红格恰为 5 个 procsub 形(F1/bare/subshell/if/multidigit),签名均为 syntax error near unexpected token、rc=2(注:box 银行曾记 3/9 与 4/9 两次,本轮逐名自洽,以本轮为准)。
  • L4 相邻:issue3491 13/13、issue1665 12/12、issue1687 7/7、parser_redirection_tests 68/0。
  • L5 lib 双边 1246/0/4 = 1246/0/4,名集 ∅;L6 -D warnings 头 rc=0,1,522 次 rustc 调用、0 诊断;L7 卫生干净。
  • GNU oracle:钉期望 9/9 逐项坐实(探针 gnu-probe.sh,vendored GNU 5.3.20)。

CI(run 43540355189,失败日志原文已核): 3 红 job(GNU 1349/1/4、macOS 1242/1/4、Linux Rust tests 0/1)唯一失败名均为 issue2875(#3292 基线);Windows tests compile check PASS,API tripwire PASS。钉 stem 在 CI 日志中 0 提及(#3430 型缺口),本轮 L2/L3 已补齐。

交集: merge-base 9410bc9f..live tip f1086b61(队长重算,含 #3520),0 个文件触及 PR 两文件——零交集例外成立,无需 update-branch。

公开欠账(X299 钉执行腿): 隧道本轮两次探针均未通(一次 Connection closed by 127.0.0.1 port 2666,一次 Permission denied (publickey,password)),钉在 Windows 的执行未证;CI 编译腿已 PASS。合入依据为 Linux 全绿 + GNU 锚点 + 编译腿,欠账记入合入报告,隧道恢复后以合并形补跑 issue3505 钉 9/9 作合入后验证。

删除节: 正文已有(无删除),与 diff 一致。

@caomengxuan666

Copy link
Copy Markdown
Member Author

合入后复核(#3519 剩余欠账):X299/Windows 钉执行腿 → pin 本身在 Windows 是红的,产品行为是对的

合并树 0079e4aa(含 e796c73b)上补跑这条 owed 腿,结论分两层:

1. cargo test --test issue3505_numbered_append_redirect_procsub 在 Windows:1 passed / 8 failed

8 个红全是文件 sink 形状(F1/bare/plain/if/fd10/simple/trunc/stderr),唯一绿的是 stdout 形状 issue3505_subshell_numbered_append_delivers。失败签名统一为 left: "",right: "2\n" —— 文件根本没生成。

根因不是产品,是钉的路径拼写:测试把 fa.display() / plain.display() 的结果直接塞进脚本,Windows 上是 D:\...\rubash-3505-f1-…\fa,未加引号;rubash 视 \U/\r 等为转义,sink 路径被改写。用同一份 target/debug/rubash.exe 对照:

{ echo X >&3; } 3>> >(wc -c > D:/repo/.../fa)   → fa = 2
{ echo X >&3; } 3>> >(wc -c > D:\repo\...\fb)   → fb 不存在

2. 用 POSIX 拼写重跑 9 个形状:9/9 全过

fa1=2、fa2=2、plain seed\nX、subshell stdout 2、if 2、fd10 2、simple 2、3> 截断 2、2>> 错误流 5,全部 rc 0。也就是说合入的解析修复在 Windows 上是正确的,欠的只是钉的可移植性。

建议

  • 保持“[bug] N>> append redirect (e.g. 3>>) rejected by the lexer #3505 剩余部分 = X299 钉 9/9”的欠账暂不销账:按现文件在 Windows 永远 1/9。
  • 补一个 test-only PR:给 sink 路径加 posix_path()(to_string_lossy().replace('\\', "/"))再进脚本;Linux 上是 no-op,Windows 上这条钉随后可 9/9。产品代码零改动。
  • 这条不要记成产品缺陷;#3505 的合并判定(Linux 全绿 + GNU 锚点 + 编译腿)不受影响。

我可以在需要时直接开这个 test-only PR(Refs #3505),按上述改法跑 Windows 9/9 后附日志。

@caomengxuan666

Copy link
Copy Markdown
Member Author

欠账闭合记录(#3519 的 X299/Windows 钉执行腿)

合并形补跑发现钉在 Windows 是 1/9(8 红全是 fa.display() 反斜杠拼写被 shell 当转义,文件从未生成;产品行为用 / 拼写 9/9 正确)。该可移植性缺陷已由 #3579 修掉并合入:

  • 96802caf test(parser): spell the #3505/#3491 pin file sinks with POSIX separators (Refs #3505 #3491)
  • Windows 复跑:issue3505_numbered_append_redirect_procsub 9 passed / 0 failed(修前 1/9);同缺陷的 issue3491_numbered_fd_output_procsub 13 passed / 0 failed(修前 5/13);parser_redirection_tests 68/0。
  • 纯测试改动,产品代码零变更;posix_path() 在 Linux/macOS 是 no-op。

因此本 PR 的合入后验证(F1/bare/plain/subshell/if/fd10/simple/trunc/stderr 九形)现在双平台都有可执行证据。Linux 侧的执行腿仍受 master 既有 api::consumer_tests::issue2875_* 红影响(CI 在 pin-stems 步骤前中止),属 #3292 基线,与本 PR 无关。

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.

1 participant