Bash可以显示一个函数的定义? [英] Can bash show a function's definition?
本文介绍了Bash可以显示一个函数的定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法来查看一个bash函数在bash定义是什么?
举例来说,说我所定义的函数 foobar的
函数foobar的{
回声我FOOBAR
}
有什么办法后来得到code,它 foobar的
运行?
$#非工作伪code
$回声$ foobar的
回声我FOOBAR
解决方案
使用键入
。如果 foobar的
是如定义你的〜/ .profile文件
:
$类型foobar的
foobar的是一个函数
{FOOBAR
回声我FOOBAR
}
这确实找出 foobar的
是,如果它被定义为它调用声明-f
函数由pmohandras解释。
Is there a way to view a bash function's definition in bash?
For example, say I defined the function foobar
function foobar {
echo "I'm foobar"
}
Is there any way to later get the code that foobar
runs?
$ # non-working pseudocode
$ echo $foobar
echo "I'm foobar"
解决方案
Use type
. If foobar
is e.g. defined in your ~/.profile
:
$ type foobar
foobar is a function
foobar {
echo "I'm foobar"
}
This does find out what foobar
was, and if it was defined as a function it calls declare -f
as explained by pmohandras.
这篇关于Bash可以显示一个函数的定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文