Skip to content

[redirection] 管线段 redirect 失败被静默丢弃/状态错:in-process 段吞错读原 stdin rc=0(GNU 段死 rc=1),中段歧义 redirect 无诊断 rc=127 (P1) #525

Closed

Description

@caomengxuan666

来源:huck 443 条 divergence issue 全量审计(issues-audit)we-diverge 增量,A 组高危 A3(含 B24 归并);huck 侧 issue #755/#145/#151/#180 互证。
审计基准:GNU bash 5.3.0(WSL stdin 法 oracle)× rubash origin/master 764b9dd debug 构建。

最小复现 1:in-process 段 redirect 失败被静默丢弃(huck#755)

echo a | { cat < /nonexistent_zq; }
echo rc=$?
GNU bash 5.3.0 rubash 764b9dd
stderr line 3: /nonexistent_zq: No such file or directory (无任何报错)
stdout (空) a(cat 落回原 stdin 把 a 读出来)
rc 1(段死) 0

最小复现 2:中段歧义 redirect 无诊断 + 段 rc 错(huck#180)

true | read x <$(echo a b) | cat
echo "${PIPESTATUS[@]}"
GNU bash 5.3.0 rubash 764b9dd
stderr $(echo a b): ambiguous redirect (无诊断)
PIPESTATUS 0 1 0 0 127 0

最小复现 3:中段失败时整体管线状态(huck#145/#151 族)

echo A | cat < /nonexistent | cat:GNU 整体 rc=0(下游继续、取末段 0);rubash rc=1。与复现 1 相同根因(in-process 段 redirect 错误传播缺失)的 rc 侧表现。

依据

  • bash 对管线每段的 redirect 打开失败:报错(带 line N)、该段夭折、PIPESTATUS 记录该段失败;绝不静默回退到原 stdin。
  • rubash 的 in-process 段吞掉 redirect 错误并回退原 stdin —— 命令在错误输入上"成功"。

跨实现互证(huck)

优先级建议

P1(静默吞 redirect 错误 + 管线状态错,双重:脚本在错误数据上静默"成功",审计定 medium-high)。
相关既有 issue:#514(未加引号未设置变量重定向误判的分类侧)、#518(redirect 错误消息保真)——本 issue 是传播/静默语义,与两者互补不重叠。

Activity

  1. added
    bug
    gnu-baseline
    P1-high
    on Oct 12, 2026
  2. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by #561 (Wave1). Vendored-bash anchors and RED-then-GREEN regression evidence in the PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-highbuggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions