bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Empty array referenced by indirection reports unbound variable


From: konsolebox
Subject: Re: Empty array referenced by indirection reports unbound variable
Date: Tue, 6 Apr 2021 23:39:31 +0800

On Tue, Apr 6, 2021 at 11:28 PM Robert Elz <kre@munnari.oz.au> wrote:
>   | @ means everything or nothing. Unbound variable errors should not apply 
> to it.
>
> I know nothing about namerefs and arrays and stuff like that,
> but did you consider the possibility that after
>
>         array=()
>
> then
>
>         array[@]
>
> is nothing, and so
>
>         __ref=array[@]
>
> is just
>
>         __ref=
>
> and consequently ${!__ref} is attempting to use '' as the name of a
> variable?

References are virtually like placeholders and don't expand the
referenced target themselves.

${!__ref} is synonymous to ${array[@]}, not ${${array[@]}}.

This is why you can do other parameter expansion features like
${!var+.} ${!var@a}.

-- 
konsolebox



reply via email to

[Prev in Thread] Current Thread [Next in Thread]