Skip to content

[redirection] redirect 词缺 set -u 检查:<<< $nope 静默空展开(GNU 报 unbound variable 继续);< $nope 误报 ambiguous redirect (P1) #535

Closed

Description

@caomengxuan666

来源:huck 443 条 divergence issue 全量审计(issues-audit)we-diverge 增量,A 组高危 A13;huck 侧 issue #606/#756/#757 互证。
审计基准:GNU bash 5.3.0(WSL stdin 法 oracle)× rubash origin/master 764b9dd debug 构建。

最小复现

set -u; cat <<< $nope; echo SAME
set -u; cat < $nope
GNU bash 5.3.0 rubash 764b9dd
<<< $nope nope: unbound variable,继续(SAME 跑,rc=0) (无任何报错,静默空展开继续)
< $nope nope: unbound variable $nope: ambiguous redirect(检查缺失,报错类型也错)

依据

  • set -u 对所有词展开生效,redirect 目标词不豁免(bash expand_words() 的 set -u 检查先于 redirect 分类)。
  • set -u 是脚本的自我防护网:rubash 静默绕过 → 拼错的文件名变量无声地变成空串/空 here-string,脚本在错误目标上继续。
  • 外部段(LEDGER huck#753/760:外部管线段子进程内 set -u 生效)与 errexit 组合 rc(huck#757)均一致,分歧集中在 in-process 段的 redirect 词检查缺失。

跨实现互证(huck)

优先级建议

P1(静默绕过 set -u 安全网:错误静默化,与 GNU 的"报错继续/报错中止"双重错位)。
相关既有 issue:#514(未加引号未设置变量重定向的分类误判,>$TMPF 零字段路径)——本 issue 是 set -u 检查缺失,互补。

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