Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: local unfunction
- X-seq: zsh-users 23290
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: local unfunction
- Date: Fri, 30 Mar 2018 11:47:18 -0700
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=z3PsZjNWf79AeMbUehwoVi+LTzMypbKwTo8cjQNdNgU=; b=Z25Rh95m3ayvBOftPHscWu0Qmj/7Xa5dxRHy3xF7+LIF8TdpALG5izz0KVWfHDH/RU 4+slUIQcfh5DjiWjKdy2BDcFw5+t5Pu187bh19loR9DMR/w7Iy8xAJJBSHgK9D1p7riU shdyYGLz1R3y6Ar5igRXmGmbBKU5S3BtjKWn8O8CsGx4xNFJ5zG2UBBHHy0F6ZebIKSs sXF8Qm7OAXjwHrqCT9qLvUOocj4u2TA68jcoZ6R5P5ZVjSSAwAAc0cCL1tg8Mvk4YK2I eiaV2Hj0gkt0WylcEoGXIxb6hhdreRp0ukSzqeGtPQEtnmjHjWIt28BN2uNC6EpnOjyP /lHQ==
- In-reply-to: <9e0faf6b-b19e-b6d6-0eb7-6ea20b2c2154@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <9e0faf6b-b19e-b6d6-0eb7-6ea20b2c2154@eastlink.ca>
On Fri, Mar 30, 2018 at 9:11 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> Is it possible to unfunction something just within another function? I've
> tried:
>
> unset -fm ....
>
> ... but the functions remain dead after the calling function returns. I can
> of course just resource them, but I'll bet the unset can be made local.
You can get that effect like this:
% zmodload zsh/parameter
% inner() { print $0 }
% outer() { local +h functions; unfunction inner; which inner }
% which inner
inner () {
print $0
}
% outer
inner not found
% which inner
inner () {
print $0
}
HOWEVER, this not "safe" with autoloaded functions that have not been
loaded yet:
% zmodload zsh/parameter
% outer() { local +h functions; unfunction inner; which inner }
% autoload -U -k inner
% which inner
inner () {
# undefined
builtin autoload -XUk
}
% outer
inner not found
% which inner
inner () {
builtin autoload -XU
}
Note that the "# undefined" tag and the -k flag have been lost;
"inner" is no longer a true autoloaded function. (I think it is
probably a bug that $functions[inner] does not have the -k flag.)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author