Created
August 20, 2012 23:29
-
-
Save andrewgross/3409237 to your computer and use it in GitHub Desktop.
Bash Callstack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If for some insane reason we really want to inspect the bash callstack | |
# we can use the BASH_LINENO, BASH_SOURCE and FUNCNAME variables | |
my_function() { | |
echo "My Function Name: ${FUNCNAME[0]}, I am at line ${BASH_LINENO[0]} of file ${BASH_SOURCE[0]}" | |
# Unless we call this from deeper down, we will get `main`, line 0, and the same filename as before | |
echo "My Parent Function: ${FUNCNAME[1]} is at line ${BASH_LINENO[1]} of file ${BASH_SOURCE[1]}" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment