variable
Bash BASH_SOURCE
Source file stack corresponding to function definitions and callers; use paths with care and check available frames.
Formal Syntax & Structure
bash syntaxbash
${BASH_SOURCE[index]}Return Value
string
Source file stack corresponding to function definitions and callers; use paths with care and check available frames.
Working Example
Example Snippetbash
cat > trace.bash <<'SCRIPT'show() { printf '%s:%s\n' "${BASH_SOURCE[0]##*/}" "${BASH_LINENO[0]}" caller 0}showSCRIPTbash trace.bash