diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-04-06 21:37:34 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-04-06 21:37:34 +0000 |
commit | 4219b23bda13ebe28c731986915faf59164fe258 (patch) | |
tree | 03d44b1a30d4e5ebba1a619c9579cc207c9038d9 | |
parent | fa191fc78257879aa34c524eafb9d1b060e706c4 (diff) | |
download | portage-4219b23bda13ebe28c731986915faf59164fe258.tar.gz portage-4219b23bda13ebe28c731986915faf59164fe258.tar.bz2 portage-4219b23bda13ebe28c731986915faf59164fe258.zip |
In dump_trace(), fix BASH_ARGV and BASH_ARGC offsets so that they are always
correct wrt eachother. Thanks to Betelgeuse for reporting.
svn path=/main/trunk/; revision=9733
-rwxr-xr-x | bin/isolated-functions.sh | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 96594d8fe..28653faf9 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -15,7 +15,7 @@ shopt -s extdebug # [whitespacing for filenames], # [whitespacing for line numbers]) dump_trace() { - local funcname="" sourcefile="" lineno="" n e s="yes" + local funcname="" sourcefile="" lineno="" s="yes" n p declare -i strip=${1:-1} local filespacing=$2 linespacing=$3 @@ -23,14 +23,19 @@ dump_trace() { # that the user will not be interested in. Therefore, the stack trace # should only show calls that come after qa_call(). (( n = ${#FUNCNAME[@]} - 1 )) + (( p = ${#BASH_ARGV[@]} )) while (( n > 0 )) ; do [ "${FUNCNAME[${n}]}" == "qa_call" ] && break (( n-- )) + (( p -= ${BASH_ARGC[${n} - 1]} )) done - (( n == 0 )) && (( n = ${#FUNCNAME[@]} - 1 )) + if (( n == 0 )) ; then + (( n = ${#FUNCNAME[@]} - 1 )) + (( p = ${#BASH_ARGV[@]} )) + fi eerror "Call stack:" - for (( p = ${#BASH_ARGV[@]} ; n > ${strip} ; n-- )) ; do + while (( n > ${strip} )) ; do funcname=${FUNCNAME[${n} - 1]} sourcefile=$(basename ${BASH_SOURCE[${n}]}) lineno=${BASH_LINENO[${n} - 1]} @@ -44,6 +49,7 @@ dump_trace() { (( p -= ${BASH_ARGC[${n} - 1]} )) fi eerror " $(printf "%${filespacing}s" "${sourcefile}"), line $(printf "%${linespacing}s" "${lineno}"): Called ${funcname}${args:+ ${args}}" + (( n-- )) done } |