最佳答案
如何在"$0"
和"${BASH_SOURCE[0]}"
之间进行选择
这个来自GNU的描述对我帮助不大。
BASH_SOURCE
An array variable whose members are the source filenames where the
corresponding shell function names in the FUNCNAME array variable are
defined. The shell function ${FUNCNAME[$i]} is defined in the file
${BASH_SOURCE[$i]} and called from ${BASH_SOURCE[$i+1]}