Skip to content

[expansion] ${!x} 于声明未赋值变量致命中止 rc=1(GNU 空展开继续 rc=0)(P1) #529

Closed

Description

@caomengxuan666

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

最小复现

declare x; echo "[${!x}]"; echo done
GNU bash 5.3.0 rubash 764b9dd
stdout [] + done (无)
stderr (无) x: invalid indirect expansion
rc 0 1(中止,done 不跑)

依据

  • declare x(无赋值)创建 declared-but-unset 变量;${!x} 对其间接展开取空串——不是致命错误。
  • rubash 把 declared-unset 当"不存在"处理,走进 invalid-indirect 致命路径,整脚本中止。
  • 边界:set -u 下 ${!ref} 未绑定的行为(!ref: unbound variable rc1)双侧一致(见 LEDGER huck#54 复验),分歧仅在 declared-unset 非严格模式这一格。

跨实现互证(huck)

优先级建议

P1(控制流错:合法惯用形 ${!x} 整脚本中止;[[ ${!x+set} ]]/间接探测类代码直接死)。

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.

  3. added a commit that references this issue on Oct 24, 2026
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