Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${(t!)nameref}; ${(t)${nested}}; Doc/zshall.1
Catching up on this (and mildly surprised no one else got to these
tidbits before me) ...
On Fri, Nov 7, 2025 at 10:46 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> A. Normally, ${(t)foo} == ${parameters[foo]}
>
> however, with namerefs that doesn't hold:
>
> $ zsh -f
> % nameref nr=foo
> % foo=42
> % print -rl ${(t)nr} ${parameters[nr]}
> scalar
> nameref-scalar
This is an effect of the general rule that named references are
followed before flags are applied. Removing the exception for (t) ==
parameters introduces an(other) exception for the flags rule.
> Not even with (!):
>
> % echo ${(t\!)nr}
> nameref
And that's an effect of the rule that the referent is NOT dereferenced
when the flags include (!).
If we make another special case for 't' then there's the also question
of whether (\!t) and (t\!) have different meanings. Some other flags
have left-to-right ordering.
> C. Here, a ${(t)…} expression expands to something not (t)-ey at all:
>
> % echo ${(t)${PATH}}
> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
That's because nested expansions work inside-out. Once you've
expanded ${PATH} you don't have a parameter any more; (t) is defined
on parameters, not on values.
> D. While testing that, I also noticed that the inner braces are required:
That's been the case forever and has nothing to do with the flags.
${$anything} is also a bad substitution and always has been.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author