Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Obtaining the names of all local variables
- X-seq: zsh-workers 35605
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Obtaining the names of all local variables
- Date: Thu, 25 Jun 2015 08:46:18 -0700
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Oliver mentioned:
> I did something like the following in _git recently. It works
> arr=( one two three )
> local $arr
This got me thinking, wouldn't it be helpful if zsh/parameter had an array
$locals that holds the names of all the local parameters? Then you could
needs_private_scope() { local -h $locals; ... }
It then occurred to me that it might be more natural to have "local" handle
this. But:
torch% () { local +m \* }
(anon): bad option: -m
Of course there's an ambiguity in both cases; given
typeset bar
scope1 () {
local foo
}
scope2 () {
local foo bar
scope1
}
Should "bar" be considered local in scope1 when called from scope2? If not,
this whole idea is somewhat moot; you'd need a way to select which scope
you want to know all the locals in, which is ugly to contemplate.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author