Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_stack () {
- STACK=""
- local i message="${1:-""}"
- local stack_size=${#FUNCNAME[@]}
- # to avoid noise we start with 1 to skip the get_stack function
- for (( i=1; i<$stack_size; i++ )); do
- local func="${FUNCNAME[$i]}"
- [ x$func = x ] && func=MAIN
- local linen="${BASH_LINENO[$(( i - 1 ))]}"
- local src="${BASH_SOURCE[$i]}"
- [ x"$src" = x ] && src=non_file_source
- STACK+=$'\n'" at: "$func" "$src" "$linen
- done
- STACK="${message}${STACK}"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement