All pastes #1964635 Raw Edit

backtrace.sh

public shellscript v1 · immutable
#1964635 ·published 2010-10-17 06:05 UTC
rendered paste body
#!/bin/bash #set -o functrace #shopt -s extdebugbacktrace() {    typeset -i i frame=0 arg=0    while caller $frame > /dev/null; do        echo "[$frame] $(caller $frame)"        ((argsInFrame = BASH_ARGC[frame]))        for ((i = 0; i < argsInFrame; ++i)); do            ((arg = totalArgs + argsInFrame - i - 1))            echo "    \$$i: ${BASH_ARGV[${arg}]}"        done        ((totalArgs += argsInFrame))        ((++frame))    done    if set -o|egrep 'functrace.*off' > /dev/null; then        echo        echo "backtrace will not work without set -o functrace"    fi    if shopt|egrep 'extdebug.*off' >> /dev/null; then        echo        echo "TO see parameters in backtraces, use shopt -s extdebug"    fi}