Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Interpret Parameter Value at Time of Function Definition
- X-seq: zsh-users 22866
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Subject: Re: Interpret Parameter Value at Time of Function Definition
- Date: Tue, 5 Sep 2017 13:51:49 -0700
- Cc: Vin Shelton <acs@xxxxxxxxxxxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0QkuQdwXdINuHEn1NuQEwZeIMsUeboaRNFICh+lKTZQ=; b=Zi65XBiLOcQbVqaNgo4xgj20T7DniIHDhg/u/Wp8RG59/ZZE8ThNqclH6vIZ+zgN8E n9fxaW4PPTg5FNnQUQ3Ob8zjbR8o5Em0xFCmZrdCcgtoAbTysErLtfBsJRTq/O0DK8we PMaR+1rpGLwR81yb39jPqXgujK9JJC4wJO+xri1qPpTsmebEeCivbDozaLn5nwV6ZnGw 9ACcotPSFAB7/zBNxfi7doZF4XdA+DT9JIj+tj8nWhtMVS6Q3zVfJxdU9ruliciHY2Ku gRfs7ICDyHzlDHERsWb9h3FKu1fnj8kXrSSAbMFagc8uddhqJlXJnrDuJQhChbL4MHcZ sweA==
- In-reply-to: <1504628227.2542836.1095967968.32944CE9@webmail.messagingengine.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>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CACeGjnVYHHZHrGcZzMeaEq-feeuG9XShK5AM9XzAs8t+W6xCZA@mail.gmail.com> <1504628227.2542836.1095967968.32944CE9@webmail.messagingengine.com>
On Tue, Sep 5, 2017 at 9:17 AM, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Vin Shelton wrote on Tue, 05 Sep 2017 09:47 -0400:
>> $ aaa=bbb
>> $ function t {
>> print aaa = \"$aaa\"
>> }
>>
>> I would like to interpret $aaa at read time [...]
>
> Declare aaa local inside the function:
That won't help if the value assigned to $aaa is itself going to
contain expansions.
As Martijn points out, the only way to get this to work is with some
kind of "read-time" evaluation. Exactly what approach is best depends
on what you want to accomplish. Does $aaa expand to executable
statements that you want to turn into part of the function code, or
does it just result in a value that you want to access later?
No matter which way you go, the key is that you'll need to quote the
function body differently than you quote the value you want assigned
to $aaa.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author