help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: expanding nameref target?
Date: Mon, 27 Feb 2023 21:00:49 -0800	[thread overview]
Message-ID: <CAH+w=7bFo3Ph7MTE5EkFfk5wYLY00MEHiQHOt9ZNWhem4fwLVw@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7bzkkKAg+TF9itdSeffk4VjfJWQnBgXonLn_cRA=ETrnQ@mail.gmail.com>

On Tue, Feb 21, 2023 at 7:59 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Tue, Feb 21, 2023 at 5:08 AM Mikael Magnusson <mikachu@gmail.com> wrote:
> >
> > Is there a way to expand a nameref to its target parameter without
> > removing the nameref attribute with +n first?
> Not yet.  Still working on that.

So ... opinions solicited before I send a patch.

In ksh emulation (and history disabled), I have this working:

% typeset -n foo=bar
% echo ${!foo}

However, that's pretty clumsy because of history expansion, so I'm
proposing the following for zsh native mode:

% typeset -n foo=bar
% echo ${(?)foo}

As an extension (more by accident than by design but possibly useful):

% echo ${(?)options}

This only works for autoloaded parameters that are not yet loaded.

For similarity with ksh mode, ${(!)foo} is a synonym for (?), but that
means we can't use (!) for anything else.  Is that a problem?

I've also made (?) [or (!)] mutually exclusive with (k) and (v).


  reply	other threads:[~2023-02-28  5:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21 13:07 Mikael Magnusson
2023-02-21 15:59 ` Bart Schaefer
2023-02-28  5:00   ` Bart Schaefer [this message]
2023-02-28  8:47     ` Oliver Kiddle
2023-02-28 10:33       ` Mikael Magnusson
2023-02-28 18:01         ` Bart Schaefer
2023-02-28 17:55       ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7bFo3Ph7MTE5EkFfk5wYLY00MEHiQHOt9ZNWhem4fwLVw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).