zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Vin Shelton <acs@alumni.princeton.edu>, zsh-users@zsh.org
Subject: Re: Interpret Parameter Value at Time of Function Definition
Date: Tue, 05 Sep 2017 16:17:07 +0000	[thread overview]
Message-ID: <1504628227.2542836.1095967968.32944CE9@webmail.messagingengine.com> (raw)
In-Reply-To: <CACeGjnVYHHZHrGcZzMeaEq-feeuG9XShK5AM9XzAs8t+W6xCZA@mail.gmail.com>

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, so that:
> 
>     aaa=ccc t
> 
> would print:
> 
>     aaa = "bbb"

Declare aaa local inside the function:

t() {
  local aaa=bbb
  typeset -p aaa
}
aaa=ccc t

... but then, if t() changes $aaa the changes won't be visible outside t().


  reply	other threads:[~2017-09-05 16:28 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 [this message]
2017-09-05 20:51   ` Bart Schaefer
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=1504628227.2542836.1095967968.32944CE9@webmail.messagingengine.com \
    --to=d.s@daniel.shahaf.name \
    --cc=acs@alumni.princeton.edu \
    --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).