Repository navigation
fix(executor): set -u unbound redirect target aborts arith/brace-group commands - #3449
Conversation
…p commands (#3429) GNU applies a compound command's redirections in the main shell (execute_cmd.c:854 do_redirections RX_ACTIVE|RX_UNDOABLE in the compound prologue shared by cm_arith/cm_group, :479-495; err_unboundvar, error.c:447), so `set -u; (( x = 1 )) > $nope` aborts the script. rubash's heredoc-error classifier read the node's synthetic words -- "((" for arithmetic, none at all for a brace group -- and contained the FatalNounset jump as if the target were a forked external child: the diagnostic printed, status was 1, and the script kept running. Teach heredoc_error_command_runs_in_main_shell that arithmetic and brace-group nodes run in the main shell, unless backgrounded or pipelined (those still fork first, GNU continues). `!` does not exempt it (GNU aborts); inside a subshell the Err still unwinds to the subshell boundary, so the parent continues as GNU does. Regression pins: tests/issue3429_set_u_arith_redirect_nounset.rs, 14 cells (5 fail-first + 9 controls), expectations byte-verified against the GNU bash 5.3.20 oracle. Refs #3429
复核:FAIL队长复核:算术命令一半修对了,花括号组一半没修——自带的两格钉在头上失败,均为 GNU 核实的真分歧。 钉:head 12/14,base 7/14(自跑,非 CI)
根因:brace 组不走分类器arith 走通用路径的 reject 门,本 PR 的守卫生效;brace 组(与 if/while/for/case/ 三方探针(21 形,GNU 5.3.20 / head / base):arith 5 形 HEAD==GNU;group-out/in 与 if/while/for/case/ 相邻面已另立 #3454
CI 红腿定性:macOS 定时抖动
返工清单
卷宗:复核员处 |
…mpound prologue (#3429) Brace groups never reach the reject gate: their redirects run through the compound prologue arms (prepare_brace_group_redirects / with_command_input_redirects), which expand the target with no nounset gate, so $nope silently becomes the empty string. Add brace_group_redirect_nounset_fatal, a prologue preflight in execute_brace_group_pipeline that scans the group's own redirect list with the walker's nounset arm before any prepare/bind side effect and unwinds as ExitCode(1) (GNU execute_cmd.c:854 compound prologue, error.c:447 err_unboundvar). if/while/for/case/[[]] are #3454's faces and are untouched. Refs #3429
复核(重审):PASS(附两项 Owed)队长复核(重审,返工新头 69a6b1c):brace 组面修对了。钉双边干净(头 14/14、基底 7/14 恰为预期 fail-first 集),三方探针 15/21 HEAD==GNU(余 6 形为已立案 #3454 的面),相邻 6 茎 40/40,头 lib 1246/0/4,卫生全绿,CI 三红均为同一 #3292 前提格。 返工内容
钉:head 14/14,base 7/14(自跑,非 CI)
三方探针(21 形,GNU 5.3.20 / head / base)15 HEAD==GNU:arith 5 形 + group-out/in + 其余对照全一致。6 HEAD!=GNU:if-c / while-c / for-c / case-c / cond-c / if-in——#3454 的面,不在本 PR 范围。 相邻 6 茎(头):40/40issue3406 9/9、issue535 12/12、issue2794 7/7、issue1130 5/5、issue1930 3/3、issue1709 4/4。 CI 全读(新头 69a6b1c,run 43280380256)7 pass + 1 skipping + 3 fail;3 fail 均为同一单格 交集(活尖 e50cea9)2 文件(pipeline_exec.rs、redirection.rs,均只来自 #3399),但 hunk 级无重叠(PR @820/@1560–1663 vs 区间 @6237+/@1949+,最近 286 行间隔);5 个 helper 符号在活尖上均在位、签名未变。须 update-branch + 合并形验证(不需 union 协议)。 Owed(合入前必须补)
卷宗:复核员处 |
|
队长裁定:合入轮 2 的 STOP 成立,执行员停得对。新头 依据:① 失败签名与 #3464 合入时队长亲核裁定的同一格完全一致——子进程印 合并形腿已备:钉 14/14(X299,bin 先建)、 |
摘要
set -u下重定向目标未绑定时,GNU 在复合命令序幕里于主 shell 做重定向(execute_cmd.c:854),脚本中止;rubash 打印诊断后继续执行。根因:walker 已报
name: unbound variable、置状态 1、返回RedirectRejection::FatalNounset,但heredoc_error_command_runs_in_main_shell按节点合成词分类——(( ... ))的词是["((", "<expr>", "))"]、brace group 根本无词——两者都被误判为 fork 子进程目标,致命跳转被 containment 吞掉。修法:分类器对 arithmetic / brace-group 节点先行返回主 shell(
&与管道段仍 fork,保持 containment;!不豁免;子 shell 内仍由子 shell 边界收敛,父 shell 继续)。回归钉:
tests/issue3429_set_u_arith_redirect_nounset.rs,14 格(5 格 fail-first + 9 格对照),期望值与 GNU bash 5.3.20 oracle 逐字节核对。Refs #3429
本 PR 删除了什么
无删除。仅新增:分类器内 25 行注释 + 守卫分支;新测试文件 226 行。未删除任何符号、文件或公开 API。
验证状态
rustfmt --check通过;本地 cargo 构建禁止(写墙),未跑。