我想在shell脚本中获取函数调用者名称,在bash中可以使用 ${FUNCNAME[1]}
${FUNCNAME[1]} 是(来电者姓名)
${FUNCNAME[0]} 是c(现在的名字)
但它不适用于zsh
即我想知道哪个函数在函数c中调用我
function a(){
c
}
function b(){
c
}
function c(){
#if a call me; then...
#if b call me; then...
}
Run Code Online (Sandbox Code Playgroud)