test/common: Reset IFS within print_backtrace()
In case IFS was modified in the environment where print_backtrace() was called, it could impact the cmd substitution used for seq'ing the main FUNCNAME loop. Example: ========== Backtrace start: ========== /home/vagrant/spdk_repo/spdk/test/common/autotest_common.sh: line 980: 1 2 3 4: syntax error in expression (error token is "2 3 4") Avoid that by resetting the IFS to its default value, but also, replace said $() with arithmetic evaluation to avoid it altogether. Signed-off-by: Michal Berger <michalx.berger@intel.com> Change-Id: I4ab098319dfae3a5356eb4fe0dbf9f4af2d2eea6 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8013 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Karol Latecki <karol.latecki@intel.com>
This commit is contained in:
parent
8742570d72
commit
9d8e1ec03c
@ -991,9 +991,11 @@ function print_backtrace() {
|
||||
local args=("${BASH_ARGV[@]}")
|
||||
|
||||
xtrace_disable
|
||||
# Reset IFS in case we were called from an environment where it was modified
|
||||
IFS=" "$'\t'$'\n'
|
||||
echo "========== Backtrace start: =========="
|
||||
echo ""
|
||||
for i in $(seq 1 $((${#FUNCNAME[@]} - 1))); do
|
||||
for ((i = 1; i < ${#FUNCNAME[@]}; i++)); do
|
||||
local func="${FUNCNAME[$i]}"
|
||||
local line_nr="${BASH_LINENO[$((i - 1))]}"
|
||||
local src="${BASH_SOURCE[$i]}"
|
||||
|
Loading…
Reference in New Issue
Block a user