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

Re: newline grief



Ray Andrews wrote on Sat, 10 Feb 2018 13:04 -0800:
> On 10/02/18 11:54 AM, Daniel Shahaf wrote:
> > Eric Cook wrote on Sat, 10 Feb 2018 14:46 -0500:
> >> for aa in "${(f)$(typeset -m 'var*')}"; do
> > There's an API for this information:
> >
> > for parameter_name in ${(k)parameters[(I)var*]} ; do
> >
> >
> What do you mean "an API"?  Application Program Interface ??

Yes.  ${parameters} is an interface, as opposed to parsing the output
of `typeset` which isn't designed to be used this way (it's designed to
be eval'd).

> $ for parameter_name in ${(k)parameters[(I)var*]} ; do set $
> {parameter_name}=; done
> 
> ... arbitrary list of variables all nulled.  This could be useful for 
> cleaning up after some messy function.

That will set them to empty.  If you want to unset them you can use
'... do unset ${parameter_name}; done', but at that point just 'unset -m
"var*"' would be equivalent and more efficient.

And you should complain to the author of that function to declare his
variables local, see WARN_CREATE_GLOBAL :-)

Cheers

Daniel



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