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

Linux 如何在函数本身中显示函数名,linux,bash,shell,busybox,Linux,Bash,Shell,Busybox,如何将函数名显示到函数中 #!/bin/sh toto() { echo "$something" } toto 应显示上述代码 toto 我正在使用busybox中的bash linux您可以使用$FUNCNAME来实现这一点 $ toto() > { > echo "this function name is $FUNCNAME" > } $ toto this function name is toto 可以使用$FUNCNAME执行此操作 $ toto(

如何将函数名显示到函数中

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

toto
应显示上述代码

toto

我正在使用busybox中的bash linux

您可以使用
$FUNCNAME
来实现这一点

$ toto()
> {
> echo "this function name is $FUNCNAME"
> }
$ toto
this function name is toto

可以使用
$FUNCNAME
执行此操作

$ toto()
> {
> echo "this function name is $FUNCNAME"
> }
$ toto
this function name is toto

这适用于我的ubuntu shell,但不适用于BusyBox bashUhms。那么,恐怕这是不可能的。请看我相信BusyBox使用的是
ash
,而不是
bash
FUNCNAME
是在2.0版中添加到
bash
的,因此不太可能出现版本问题。这适用于我的ubuntu shell,但不适用于BusyBox bashUhms。那么,恐怕这是不可能的。请看我相信BusyBox使用的是
ash
,而不是
bash
FUNCNAME
在2.0版中添加到了
bash
,因此不太可能出现版本问题。