On Sat, 27 Dec 2025 at 11:39, Ore Redstone <[email protected]>
wrote:

> I'm using the name reference to get the length of an object from an array,
> but it outputs `0`.
>
> *[…]*$ echo ${#c}   *# Expected result: 1*
> 0
> *[…]*
> $ echo $BASH_VERSION
> 5.2.21(1)-release


This appears to operate correctly in Bash v5.3.0:
```
$ b=(AAAAAA BBBBB CCCC)
$ echo "${#b[2]}"
4
$ declare -ng c=b[2]
$ echo "$c"
CCCC
$ echo "${#c}"
4
$ declare -ng c=b
$ echo "${#c}"
6
$ echo $BASH_VERSION
5.3.0(63)-maint
$ uname -a
Linux secrethostname 6.12.57+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian
6.12.57-1 (2025-11-05) x86_64 GNU/Linux
```

According to README-5.3, in the section details changes between
bash-5.2-release and bash-5.3-alpha:

> hh. Fixed nameref expansion where nameref values are valid length expansion
>     expressions but invalid identifiers.

(Whilst not exactly describing your issue, fixing either issue would have
modified the same code.)

-Martin

Reply via email to