Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: r/w access to calling function's $@



On Tue, 13 May 2014 18:01:40 +0200
Roman Neuhauser <neuhauser@xxxxxxxxxx> wrote:
> zparseopts can modify $@ in the calling scope.  i'm playing with my own,
> slightly different option parser.  what do i have to do to get access to
> this feature?

The trick is it's not a different scope, it's just a builtin within the
current function scope.  The equivalent would be to implement your own C
plugin, which I presume is not what you're after.  Failing that you
have to do something nasty like using "eval" to avoid exposing the
point where it gets transferred to the current argument set.

Passing back values has always been one of my chief annoyances about
shell functions, nor do I think generically allowing references to
higher level parameters is a good idea.  We need something more
specific that I haven't thought of to do parameter references.

(While I've been distracting you, Bart will meanwhile have thought
of a way of doing it.)

pws



Messages sorted by: Reverse Date, Date, Thread, Author