]> git.ipfire.org Git - people/stevee/network.git/commitdiff
Enhance backtrace with called binary.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 18 May 2013 10:34:41 +0000 (12:34 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 19 May 2013 09:06:39 +0000 (11:06 +0200)
So it is easier to find out which command has been
executed.

functions.list
functions.util

index 3110357f2604f35252fc63d7244802d6734222e0..062df27eb99d30fd20be1c4d5602cd2a4c987e40 100644 (file)
@@ -119,3 +119,13 @@ function list_join() {
 
        print "${ret:${#delim}}"
 }
+
+function list_reverse() {
+       local reversed arg
+       for arg in $@; do
+               reversed="${arg} ${reversed}"
+       done
+
+       print "${reversed}"
+       return ${EXIT_OK}
+}
index b975b6a0b926b25a8b58663df99cfeddcd42106b..2eef4a7a77bd260547fefa7d887b9997167d3d1f 100644 (file)
@@ -260,7 +260,14 @@ function backtrace() {
        local i source
        for i in $(seq ${start} ${#BASH_SOURCE[*]}); do
                [ -z "${FUNCNAME[${i}]}" ] && continue
-               [ "${FUNCNAME[${i}]}" == "main" ] && continue
+
+               # Print called binary with arguments.
+               if [ "${FUNCNAME[${i}]}" == "main" ]; then
+                       local args="$(list_reverse ${BASH_ARGV[*]})"
+                       printf -v source "%20s" "$0"
+                       error_log "  ${source} ${args}"
+                       continue
+               fi
 
                source=${BASH_SOURCE[$(( ${i} + 1 ))]}
                error_log "  $(printf "%20s" "'${FUNCNAME[${i}]}'") called from ${source:-<shell>}:${BASH_LINENO[${i}]}"