如何显示zsh的函数定义(如bash的"类型MYFUNC")? [英] How to show zsh function definition (like bash "type myfunc")?
本文介绍了如何显示zsh的函数定义(如bash的"类型MYFUNC")?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何显示的zsh函数的定义? Foo类型
不给的定义。
在bash:
的bash $函数foo(){回声您好; }bash的$ foo的
你好bash的$ Foo类型
foo是一个函数
富()
{
你好回声
}
在zsh的:
的zsh $函数foo(){回声您好; }zsh的$ foo的
你好zsh的$ Foo类型
foo是一个shell功能
解决方案
zsh的成语是何处
的 -f
标记打印功能定义:
的zsh $何处-f富
富(){
你好回声
}
zsh的$
在zsh中,键入
被定义为等同于何处-v
,所以你可以继续使用键入
,但你需要使用 -f
参数:
的zsh $型-f富
富(){
你好回声
}
zsh的$
最后,在zsh的这
被定义为等同于何处-c
- 在 csh类的格式,因此此foo
将产生相同的结果。
男人zshbuiltins
的这一切。
How do I show the definition of a function in zsh? type foo
doesn't give the definition.
In bash:
bash$ function foo() { echo hello; }
bash$ foo
hello
bash$ type foo
foo is a function
foo ()
{
echo hello
}
In zsh:
zsh$ function foo() { echo hello; }
zsh$ foo
hello
zsh$ type foo
foo is a shell function
解决方案
The zsh idiom is whence
, the -f
flag prints function definitions:
zsh$ whence -f foo
foo () {
echo hello
}
zsh$
In zsh, type
is defined as equivalent to whence -v
, so you can continue to use type
, but you'll need to use the -f
argument:
zsh$ type -f foo
foo () {
echo hello
}
zsh$
And, finally, in zsh which
is defined as equivalent to whence -c
- print results in csh-like format, so which foo
will yield the same results.
man zshbuiltins
for all of this.
这篇关于如何显示zsh的函数定义(如bash的"类型MYFUNC")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文