我在我的 .bash_profile
中定义了几个不同的函数。我通常会记住函数的名称,但想在运行之前快速浏览一下代码。
在我的 .bash_profile
中,我有以下内容:
gpm () {
echo "git pull origin master"
git pull origin master
}
现在我想在 Bash 中运行这样的东西:
$ <something> gpm
预期结果:不执行函数只打印出函数定义本身。
最佳答案
编辑:最佳答案不是这个,而是下面的另一个。
这个答案曾经说过,您可以使用内置的 type
在 bash 中获得函数定义,例如输入 gpm
。但是,按照其他答案中的描述使用 declare
在各个方面都更好。
关于bash - 如何在 Bash 中打印函数定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9894872/