diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 518c116..734f874 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -114,18 +114,21 @@ bats_capture_stack_trace() { fi done - BATS_SOURCE="$(bats_frame_filename "${BATS_CURRENT_STACK_TRACE[0]}")" - BATS_LINENO="$(bats_frame_lineno "${BATS_CURRENT_STACK_TRACE[0]}")" + bats_frame_filename "${BATS_CURRENT_STACK_TRACE[0]}" 'BATS_SOURCE' + bats_frame_lineno "${BATS_CURRENT_STACK_TRACE[0]}" 'BATS_LINENO' } bats_print_stack_trace() { local frame local index=1 local count="${#@}" + local filename + local lineno for frame in "$@"; do - local filename="$(bats_trim_filename "$(bats_frame_filename "$frame")")" - local lineno="$(bats_frame_lineno "$frame")" + bats_frame_filename "$frame" 'filename' + filename="$(bats_trim_filename "$filename")" + bats_frame_lineno "$frame" 'lineno' if [ $index -eq 1 ]; then echo -n "# (" @@ -133,7 +136,8 @@ bats_print_stack_trace() { echo -n "# " fi - local fn="$(bats_frame_function "$frame")" + local fn + bats_frame_function "$frame" 'fn' if [ "$fn" != "$BATS_TEST_NAME" ]; then echo -n "from function \`$fn' " fi @@ -151,8 +155,11 @@ bats_print_stack_trace() { bats_print_failed_command() { local frame="$1" local status="$2" - local filename="$(bats_frame_filename "$frame")" - local lineno="$(bats_frame_lineno "$frame")" + local filename + local lineno + + bats_frame_filename "$frame" 'filename' + bats_frame_lineno "$frame" 'lineno' local failed_line="$(bats_extract_line "$filename" "$lineno")" local failed_command="$(bats_strip_string "$failed_line")" @@ -166,12 +173,12 @@ bats_print_failed_command() { } bats_frame_lineno() { - printf '%s\n' "${1%% *}" + printf -v "$2" '%s' "${1%% *}" } bats_frame_function() { local __bff_function="${1#* }" - printf '%s\n' "${__bff_function%% *}" + printf -v "$2" '%s' "${__bff_function%% *}" } bats_frame_filename() { @@ -181,7 +188,7 @@ bats_frame_filename() { if [ "$__bff_filename" = "$BATS_TEST_SOURCE" ]; then __bff_filename="$BATS_TEST_FILENAME" fi - printf '%s\n' "$__bff_filename" + printf -v "$2" '%s' "$__bff_filename" } bats_extract_line() {