【发布时间】:2013-07-17 11:24:21
【问题描述】:
如何在函数中显示函数名?
#!/bin/sh
toto()
{
echo "$something"
}
toto
上面的代码应该会显示
toto
我正在使用来自busybox的bash linux
【问题讨论】:
如何在函数中显示函数名?
#!/bin/sh
toto()
{
echo "$something"
}
toto
上面的代码应该会显示
toto
我正在使用来自busybox的bash linux
【问题讨论】:
您可以使用$FUNCNAME 这样做。
$ toto()
> {
> echo "this function name is $FUNCNAME"
> }
$ toto
this function name is toto
【讨论】:
ash,而不是bash。 FUNCNAME 是在 2.0 版中添加到 bash 中的,因此不太可能是版本问题。