diff --git a/src/log_helpers.sh b/src/log_helpers.sh index e6fb51c..a1341cf 100644 --- a/src/log_helpers.sh +++ b/src/log_helpers.sh @@ -32,9 +32,10 @@ function _log_x() { fi fi - for line in $(echo -e "$lines"); do + lines=$(echo -e "$lines") + while IFS= read -r line; do echo_err "${prefix}${line}" - done + done <<< "$lines" } function log_error() { diff --git a/test/log_helpers.bats b/test/log_helpers.bats index 2dc92b1..dfae74c 100644 --- a/test/log_helpers.bats +++ b/test/log_helpers.bats @@ -63,22 +63,22 @@ Baz" @test "log_error should print GHA error command with multiple errors when multiline message provided (using \n)" { GITHUB_ACTIONS="true" - run log_error "Foo" "Bar\nBaz" + run log_error "Foo Bar" "Hello 1\nHello 2" assert_success - assert_output "::error title=Foo::Bar -::error title=Foo::Baz" + assert_output "::error title=Foo Bar::Hello 1 +::error title=Foo Bar::Hello 2" } @test "log_error should print GHA error command with multiple errors when multiline message provided (using multiple arguments)" { GITHUB_ACTIONS="true" - run log_error "Foo" "Bar -Baz" + run log_error "Foo Bar" "Hello 1 +Hello 2" assert_success - assert_output "::error title=Foo::Bar -::error title=Foo::Baz" + assert_output "::error title=Foo Bar::Hello 1 +::error title=Foo Bar::Hello 2" } @test "log_warning should print warning with title" {