mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-08 05:26:58 +02:00
The "function" keyword is superfluous, not in POSIX, is inconsistent between bash files, and generally makes me angry. So convert every instance to the form: foo() { BUG=None TEST=`cbuildbot x86-generic-paladin` works Change-Id: I97f5ca30a3edfef7222b1e08ac23917dc613b556 Reviewed-on: https://gerrit.chromium.org/gerrit/22467 Reviewed-by: David James <davidjames@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
# Code used for bash stack dumps included by common.sh when we're in
|
|
# bash mode.
|
|
|
|
# Output a backtrace all the way back to the raw invocation, suppressing
|
|
# only the _dump_trace frame itself.
|
|
|
|
_dump_trace() {
|
|
local j n p func src line args
|
|
p=${#BASH_ARGV[@]}
|
|
for (( n = ${#FUNCNAME[@]}; n > 1; n-- )); do
|
|
func=${FUNCNAME[${n} - 1]}
|
|
src=${BASH_SOURCE[${n}]##*/}
|
|
line=${BASH_LINENO[${n} - 1]}
|
|
args=
|
|
if [[ -z ${BASH_ARGC[${n} -1]} ]]; then
|
|
args='(args unknown, no debug available)'
|
|
else
|
|
for (( j = 0 ; j < ${BASH_ARGC[${n} -1]} ; ++j )); do
|
|
args="${args:+${args} }'${BASH_ARGV[$(( p - j - 1 ))]}'"
|
|
done
|
|
! (( p -= ${BASH_ARGC[${n} - 1]} ))
|
|
fi
|
|
if [[ $n == ${#FUNCNAME[@]} ]]; then
|
|
error "script called: ${0##/*} ${args}"
|
|
error "Backtrace: (most recent call is last)"
|
|
else
|
|
error "$(printf ' file %s, line %s, called: %s %s' \
|
|
"${src}" "${line}" "${func}" "${args}")"
|
|
fi
|
|
done
|
|
}
|