Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Refering to overlaid variable from within a function
- X-seq: zsh-users 15391
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Refering to overlaid variable from within a function
- Date: Sun, 12 Sep 2010 02:24:19 -0400
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d200912; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=a0qyQKl+96EOzN8MCdIMhTO3Ls0rH+ubEiB17iCXsVw=; b=eEXLv/Jcu6fBB3/RMI7cy83sD+dPDyd1v8/x/D29O9me0QOm9zjxQNSNzlxapfdadKh3grDYftMr31Tl6XVZJWogEYzANFyKzWd3PcznOrCcmV+sAgw9Yl9k5KhF6FWdeQSHu3m2FTa7mHqrpOhJgW7Hrlbjri4DLbKlfxuRGo0=;
- In-reply-to: <100910073557.ZM21299@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20100910061319.GA73504@xxxxxxxxxxxxxxxxxxxx> <20100910094157.3f128d4d@xxxxxxxxxxxxxxxxxxxxxxxxx> <100910073557.ZM21299@xxxxxxxxxxxxxxxxxxxxxx>
On 2010-09-10 at 07:35 -0700, Bart Schaefer wrote:
> On Sep 10, 2:13am, Phil Pennock wrote:
> }
> } Is there a way to refer to variables as they exist in the context of the
> } caller of a function, so that you can use a name but not have to worry
> } about the caller's names?
>
> Yes, but it's sneaky.
>
> bar () {
> local a="this is bar's $1"
> print $a
> trap "$1+=\" and \"${(q-)a}" EXIT
> }
> foo () {
> local a="this is foo's a"
> print $a
> bar a
> print $a
> }
>
> Now run "foo".
% foo
this is foo's a
this is bar's a
bar:3: error in flags
Tried with 4.3.10 and 4.3.9.
Dropping the '-' from the parameter expansion flags does the trick.
I'll think on it some more, to deal with the unique-ified arrays needed
for the sets. I might just end up switching back to working on the
positional parameters.
Thanks,
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author