Skip to content

Commit

Permalink
functions.sh: Add backtrace()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicowilliams committed Oct 12, 2021
1 parent ee9fcb5 commit fe03291
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,16 @@ verify_sig() {
||
die "could not verify signature on $body with $pubkey"
}

backtrace () {
local -i n=${#FUNCNAME[@]}
local -i i

for ((i=1; i<n; i++)); do
printf '%*s' "$i" '' # indent
printf 'at: %s(), %s, line %s\n' \
"${FUNCNAME[$i]}" \
"${BASH_LINENO[$((i-1))]}" \
"${BASH_SOURCE[i]}"
done
}

0 comments on commit fe03291

Please sign in to comment.