如何在函数本身中显示函数名称

时间:2013-07-17 11:24:22

标签: linux bash shell busybox

如何在函数中显示函数名称?

#!/bin/sh
toto()
{
    echo "$something"
}

toto

上面的代码应该显示

toto

我在busybox中使用bash linux

1 个答案:

答案 0 :(得分:5)

您可以使用$FUNCNAME来执行此操作。

$ toto()
> {
> echo "this function name is $FUNCNAME"
> }
$ toto
this function name is toto
相关问题