Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Evaluating parameters in general-purpose widgets
- X-seq: zsh-users 23099
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Evaluating parameters in general-purpose widgets
- Date: Fri, 19 Jan 2018 18:47:43 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=X3M+qr ohMaMT5TlfGKBSlNY1PBe1jiQLvL4JFUaQlE8=; b=GDA4G/1rPmur0F6nHXtqsP kKSfA7YRVGbrn8Ff81yowNTZjV0nbiPVSIygW3a7F8YCY/kUDu0uZS951XyQYD1I kNxnsI22XzmVUw3HtxZsE2r4Onisqo6NfOPGVacwxZ2cT+iZkKHhmcZKhD4Z0Yn0 4UCKHvZjeowEo/i61gMTUgvzd9j98UY70Lw1ZLHzfpKO1na4rmj3pQMgEWb6rqND jXiZAnyQzqcUgAEEnlAuxMLzkqU3z0Lnqy5rtMZd4LQlgshyshb/L2OGtUSa7kGH tEeUeLXSiULDCmSUVRke365byXi8EzmJatARrB6E45DND6Ye5o2SipnpZrv5oaOw ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=X3M+qr ohMaMT5TlfGKBSlNY1PBe1jiQLvL4JFUaQlE8=; b=MezkZuTlV6+kQQ9NPNVxYg mxULCWoY2ZV1SHGKQMNHUfXHBWrC2BdRWnds/ewOwFkSwNSlBvQwqe5m0Cwv7JK5 RZKx4W8PZL+PbLw5KZXYChh+X5yS4hgDVtUS/UoF2X0A8STjlgAaB8IkR5QR6xUb gXq1X4vfJul2KkBC73ZGaCr2lCNkKN1NvkXL2+xzy5swh7Fnibz7dG8FPQFutp2A GeHuDITKBVnFJND2cGbXZvG+WkYziWwB3IKBlsQFCCdW1ypJultnJFeMMDkna0r/ 1Z5ufz0UiCW9DRECxORa0sMWKw4vi/fUN6vGHUtXzr2mo+wTjkteNszetCpATQ2g ==
- In-reply-to: <CAH+w=7Z85sfMpMvVkOWfFROU02e3UdOEO1UVBwR3cBideOVj4Q@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20180119002154.ssgbaowmrjvehme5@tarpaulin.shahaf.local2> <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@xxxxxxxxxxxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author