>Why wouldn't they be transparent for all word expansions? That seems like
>fewer special cases.
I see your point, and I agree. The current semantics of @A and @a expansions as
applied to namerefs makes sense to me now. The behavior is just somewhat
under-documented.
I was looking for a way to efficiently determine whether a variable was a
nameref or not, and it seems that the ${v@A} expansion can be used for that.
For a defined variable $v [[ ${v@A} =~
^(declare[[:blank:]]-[[:alpha:]]+[[:blank:]])?$v(=|$) ]] evaluates to false if
and only if v is a nameref. This
follows in part from the fact that a nameref cannot reference its own name. The
regex can probably be simplified.
So I am a happy camper.
-Mark
On Monday, October 20, 2025 at 01:24:18 PM PDT, Chet Ramey
<[email protected]> wrote:
On 10/17/25 4:41 PM, Mark March wrote:
>> Is this enough of a special case to make it different?
>
> Well, to me the @A and @a expansion operators always looked different from
> all the others as they expand to the *attributes* of the variable rather than
> to a function of the variable's *value*.
Sure, but they still act on the target/value of a nameref variable, just
like all the other word expansions.
>Namerefs are transparent for get-value/set-value type operations. Should they
>be transparent for
attribute-focused expansions as well?
Why wouldn't they be transparent for all word expansions? That seems like
fewer special cases.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/