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"