]> git.ipfire.org Git - people/stevee/network.git/commitdiff
backtrace: Show something in backtrace when a function was called on a shell.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Jun 2012 09:46:35 +0000 (09:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Jun 2012 09:46:35 +0000 (09:46 +0000)
functions.util

index 9228fd02421ec70e42c7eb9189c6b350b4783a44..8abae1812aaf483d47cd0e6529ed0c640d072951 100644 (file)
@@ -187,12 +187,13 @@ function backtrace() {
        echo # Empty line
        error_log "Backtrace (most recent call in first line):"
 
-       local i
+       local i source
        for i in $(seq ${start} ${#BASH_SOURCE[*]}); do
                [ -z "${FUNCNAME[${i}]}" ] && continue
                [ "${FUNCNAME[${i}]}" == "main" ] && continue
 
-               error_log "  $(printf "%20s" "'${FUNCNAME[${i}]}'") called from ${BASH_SOURCE[$(( ${i} + 1 ))]}:${BASH_LINENO[${i}]}"
+               source=${BASH_SOURCE[$(( ${i} + 1 ))]}
+               error_log "  $(printf "%20s" "'${FUNCNAME[${i}]}'") called from ${source:-<shell>}:${BASH_LINENO[${i}]}"
        done
 }