В BASH можно ли получить имя функции в теле функции? Принимая следующие коды в качестве примера, я хочу напечатать имя функции "Test" в своем теле, но "$ 0", похоже, ссылается на имя script вместо имени функции. Итак, как получить имя функции?
#!/bin/bash
function Test
{
if [ $# -lt 1 ]
then
# how to get the function name here?
echo "$0 num" 1>&2
exit 1
fi
local num="${1}"
echo "${num}"
}
# the correct function
Test 100
# missing argument, the function should exit with error
Test
exit 0