zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Re: Evaluating parameters in general-purpose widgets
Date: Fri, 19 Jan 2018 18:47:43 +0000	[thread overview]
Message-ID: <1516387663.3550697.1241394160.58ECD3D2@webmail.messagingengine.com> (raw)
In-Reply-To: <CAH+w=7Z85sfMpMvVkOWfFROU02e3UdOEO1UVBwR3cBideOVj4Q@mail.gmail.com>

Bart Schaefer wrote on Thu, 18 Jan 2018 22:25 -0800:
> On Thu, Jan 18, 2018 at 4:21 PM, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> >
> > Is it safe for zsh-syntax-highlighting to evaluate parameter expansions
> > in the input?
> 
> Depending on how costly you're willing to make this, you could always
> use "${$(print -nr -- "$foobar"X)%X}" to assure the parameter is
> evaluated where it can't have any effects on the current shell.

That's a handy idiom :-).

In this case, however, I can think of two issues with it: it wouldn't be
performant on platforms where fork() is expensive, and it would mess
with modules-provided parameters whose getfn uses out-of-process state.

Therefore, I'm currently inclined to
.
    if $parameters[foobar] == *special* ; then
        # leave it alone
    else
        # expand it using ${(P)${:-foobar}}
    fi
.
to sidestep module-provided parameters entirely.

Thanks,

Daniel

P.S. For anyone else reading this: using ${(P)} like that is only
     correct when SH_WORD_SPLIT hasn't been set.


      parent reply	other threads:[~2018-01-19 18:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19  0:21 Daniel Shahaf
2018-01-19  6:25 ` Bart Schaefer
2018-01-19  6:27   ` Bart Schaefer
2018-01-19 18:47   ` Daniel Shahaf [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=1516387663.3550697.1241394160.58ECD3D2@webmail.messagingengine.com \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.vuxu.org/mirror/zsh/

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).