mirror of
https://github.com/sstephenson/bats.git
synced 2025-03-04 07:49:50 +01:00
exec-test: Use printf -v in bats_strip_string
This commit is contained in:
parent
eaa151fb69
commit
3bc03796e9
|
@ -162,8 +162,10 @@ bats_print_failed_command() {
|
||||||
bats_frame_lineno "$frame" 'lineno'
|
bats_frame_lineno "$frame" 'lineno'
|
||||||
|
|
||||||
local failed_line="$(bats_extract_line "$filename" "$lineno")"
|
local failed_line="$(bats_extract_line "$filename" "$lineno")"
|
||||||
local failed_command="$(bats_strip_string "$failed_line")"
|
local failed_command
|
||||||
echo -n "# \`${failed_command}' "
|
|
||||||
|
bats_strip_string "$failed_line" 'failed_command'
|
||||||
|
printf '%s' "# \`${failed_command}' "
|
||||||
|
|
||||||
if [ $status -eq 1 ]; then
|
if [ $status -eq 1 ]; then
|
||||||
echo "failed"
|
echo "failed"
|
||||||
|
@ -198,8 +200,8 @@ bats_extract_line() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bats_strip_string() {
|
bats_strip_string() {
|
||||||
local string="$1"
|
[[ "$1" =~ ^[[:space:]]*(.*)[[:space:]]*$ ]]
|
||||||
printf "%s" "$string" | sed -e "s/^[ "$'\t'"]*//" -e "s/[ "$'\t'"]*$//"
|
printf -v "$2" '%s' "${BASH_REMATCH[1]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
bats_trim_filename() {
|
bats_trim_filename() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user