From 3bc03796e9274e10fe412700e6128d7538ab3046 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 10:07:22 -0500 Subject: [PATCH] exec-test: Use printf -v in bats_strip_string --- libexec/bats-exec-test | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index fce77aa..55f3281 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -162,8 +162,10 @@ bats_print_failed_command() { bats_frame_lineno "$frame" 'lineno' local failed_line="$(bats_extract_line "$filename" "$lineno")" - local failed_command="$(bats_strip_string "$failed_line")" - echo -n "# \`${failed_command}' " + local failed_command + + bats_strip_string "$failed_line" 'failed_command' + printf '%s' "# \`${failed_command}' " if [ $status -eq 1 ]; then echo "failed" @@ -198,8 +200,8 @@ bats_extract_line() { } bats_strip_string() { - local string="$1" - printf "%s" "$string" | sed -e "s/^[ "$'\t'"]*//" -e "s/[ "$'\t'"]*$//" + [[ "$1" =~ ^[[:space:]]*(.*)[[:space:]]*$ ]] + printf -v "$2" '%s' "${BASH_REMATCH[1]}" } bats_trim_filename() {