From a3396cbc891d5f76832cd0cae65bf427c35bfb6c Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Tue, 14 Feb 2017 16:22:02 -0500 Subject: [PATCH] exec-test: Refactor bats_frame_* functions Preserves existing behavior. Next step will be to take the target variable name as the second argument. --- libexec/bats-exec-test | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index bdce3c8..518c116 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -166,28 +166,22 @@ bats_print_failed_command() { } bats_frame_lineno() { - local frame="$1" - local lineno="${frame%% *}" - echo "$lineno" + printf '%s\n' "${1%% *}" } bats_frame_function() { - local frame="$1" - local rest="${frame#* }" - local fn="${rest%% *}" - echo "$fn" + local __bff_function="${1#* }" + printf '%s\n' "${__bff_function%% *}" } bats_frame_filename() { - local frame="$1" - local rest="${frame#* }" - local filename="${rest#* }" + local __bff_filename="${1#* }" + __bff_filename="${__bff_filename#* }" - if [ "$filename" = "$BATS_TEST_SOURCE" ]; then - echo "$BATS_TEST_FILENAME" - else - echo "$filename" + if [ "$__bff_filename" = "$BATS_TEST_SOURCE" ]; then + __bff_filename="$BATS_TEST_FILENAME" fi + printf '%s\n' "$__bff_filename" } bats_extract_line() {