FUNCNAME

要获取当前函数的名称 - 键入:

my_function()
{
    echo "This function is $FUNCNAME"    # This will output "This function is my_function"
}

如果在函数外部输入,该指令将不返回任何内容:

my_function

echo "This function is $FUNCNAME"    # This will output "This function is"