如何删除/移除 shell 函数?
我已经这样做了:
$ z() { echo 'hello world'; }
我该如何摆脱它?
I have done this:
$ z() { echo 'hello world'; }
How do I get rid of it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将取消设置名为 z 的函数。 有几个人回答说:
但是如果你有一个函数和一个名为 z 的变量,则只有变量会被取消设置,而函数不会被取消设置。
Will unset the function named z. A couple people have answered with:
but if you have a function and a variable named z only the variable will be unset, not the function.
在 Zsh 中:
这是
unhash -f z
或unset -f z
的另一个(可以说更好)名称,并且与以下家族的其余部分一致:unset
unhash
unalias
unlimit
unsetopt
如果对此类事情有疑问,请输入
un查看完整列表。
(稍微相关:拥有像
realases
、refunctions
、resetopts
、reenv
等来“重新源
”相应的文件(如果您已将它们分开/分组)。)In Zsh:
That's another (arguably better) name for
unhash -f z
orunset -f z
and is consistent with the rest of the family of:unset
unhash
unalias
unlimit
unsetopt
When in doubt with such things, type
un<tab>
to see the complete list.(Slightly related: It's also nice to have functions/aliases like
realiases
,refunctions
,resetopts
,reenv
, etc to "re-source
" respective files, if you've separated/grouped them as such.)