Skip to content

[bug] ${#UNSET} unbound-variable diagnostic leaks the # operator into the name (#UNSET vs UNSET) #200

Closed

Description

@caomengxuan666

Found by the suite2 ledger run (new-exp.tests:531 and array.tests:271 under set -u), WSL GNU Bash 5.3.0 baseline.

Repro (LF script, both sides)

set -u
echo "${#UNSET}"

GNU Bash 5.3.0 (stderr)

probe.sh: line 2: UNSET: unbound variable

rubash (target-wire/debug/rubash.exe, master 26728da) (stderr)

probe.sh: line 2: #UNSET: unbound variable

For ${#name} the reported variable name must be name — the # length operator must not leak into the unbound-variable diagnostic. Same shape in the array suite: ( echo ${#narray[4]} ) under set -u reports #narray[4] instead of GNU's narray[4]. Exit status matches (1); only the message name text is wrong, but scripts that scrape the variable name out of the message (set -u handlers) get a poisoned name.

GNU anchor

  • subst.c:9777 parameter_brace_expand() length branch (${#name}) — passes the de-#'d name to the unbound-variable error
  • error path: err_unbound / unbound_variable reporting in subst.c

Artifacts

  • probe: target-suite2/probes/p4-unbound-name.sh (+ .gnu.err/.rb.err)
  • suite artifacts: target-suite2/results/new-exp/{gnu,rb}.err line 15; array/{gnu,rb}.err line 18

Activity

  1. added
    bug
    gnu-baseline
    on Sep 27, 2026
  2. caomengxuan666 commented on Sep 27, 2026

    @caomengxuan666
    MemberAuthor

    已修复并合入 master(commit ddeabd56)。${#UNSET} 的 unbound variable 诊断现在按 GNU subst.c:9944-9951(err_unboundvar(name+1))报告去掉 # 的名字:#UNSET→UNSET、#1→1、#a[0]→a[0] 均已对 WSL GNU 5.3.0 探针验证。感谢报告!

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

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions