print_stack() { echo "stack on:" stack_deep=${#FUNCNAME[@]} for ((i=1; i<$stack_deep; i++)); do echo "#$i $0," ${FUNCNAME[$i]}:${BASH_LINENO[`expr $i - 1`]} done } main() { print_stack } main