zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Vin Shelton <acs@alumni.princeton.edu>, Zsh Users <zsh-users@zsh.org>
Subject: Re: Interpret Parameter Value at Time of Function Definition
Date: Tue, 5 Sep 2017 13:51:49 -0700	[thread overview]
Message-ID: <CAH+w=7YJo00BhHnMCrG+=5+s-JRnnGn8f8xRX83AV071F6_QOg@mail.gmail.com> (raw)
In-Reply-To: <1504628227.2542836.1095967968.32944CE9@webmail.messagingengine.com>

On Tue, Sep 5, 2017 at 9:17 AM, Daniel Shahaf <d.s@daniel.shahaf.name> 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.


  reply	other threads:[~2017-09-05 20:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-05 13:47 Vin Shelton
2017-09-05 16:17 ` Daniel Shahaf
2017-09-05 20:51   ` Bart Schaefer [this message]
2017-09-05 18:21 ` Martijn Dekker
2017-09-06  3:08   ` Ray Andrews
2017-09-06  4:16     ` 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:
  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='CAH+w=7YJo00BhHnMCrG+=5+s-JRnnGn8f8xRX83AV071F6_QOg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=acs@alumni.princeton.edu \
    --cc=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).