Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. function get_stack () {
  2. STACK=""
  3. local i message="${1:-""}"
  4. local stack_size=${#FUNCNAME[@]}
  5. # to avoid noise we start with 1 to skip the get_stack function
  6. for (( i=1; i<$stack_size; i++ )); do
  7. local func="${FUNCNAME[$i]}"
  8. [ x$func = x ] && func=MAIN
  9. local linen="${BASH_LINENO[$(( i - 1 ))]}"
  10. local src="${BASH_SOURCE[$i]}"
  11. [ x"$src" = x ] && src=non_file_source
  12.  
  13. STACK+=$'\n'" at: "$func" "$src" "$linen
  14. done
  15. STACK="${message}${STACK}"
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement