Skip to content

Commit e82402f

Browse files
Fix broken pipe errors
1 parent ad3b159 commit e82402f

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

  • libexec/bats-core

libexec/bats-core/bats

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,7 @@ bats_tee() { # <output-file> <command...>
485485
local output_file=$1 status=0
486486
shift
487487
exec 3<&1 # use FD3 to get around pipe
488-
{
489-
while IFS= read -r line; do
490-
printf "%s\n" "$line" || exit 1 # write to command/file
491-
printf "%s\n" "$line" >&3 # write to our stdout
492-
done
493-
if [[ -n "$line" ]]; then
494-
printf "%s\n" "$line" # write to command/file
495-
printf "%s\n" "$line" >&3 # write to our stdout
496-
fi
497-
} | "$@" >"$output_file" || status=$?
488+
tee >(cat >&3) | "$@" >"$output_file" || status=$?
498489
if (( status != 0 )); then
499490
printf "ERROR: command \`%s\` failed with status %d\n" "$*" "$status" >&2
500491
fi

0 commit comments

Comments
 (0)