Skip to content

--keep-empty-lines causes an empty line to be added to output #708

@jrmash

Description

@jrmash

Describe the bug
Invoking the run command with --keep-empty-lines causes an empty line to be appended to the end of the output.

To Reproduce

bats_require_minimum_version 1.9.0

f::lines() {
    echo "Line #1"
    echo "Line #2"
}

@test "f::lines produces only 2 lines -- Test shows 2 lines, 0 empty lines" {
    run f::lines
    [ "${lines[0]}" == "Line #1" ]
    [ "${lines[1]}" == "Line #2" ]
    [ "${#lines[*]}" -eq 2 ]
}
@test "f::lines produces only 2 lines -- --keep-empty-lines adds an empty line to output" {
    run --keep-empty-lines f::lines
    [ "${lines[0]}" == "Line #1" ]
    [ "${lines[1]}" == "Line #2" ]
    
    ## Third line exists and is empty
    [ "${lines[2]}" == "" ]
    [ "${#lines[*]}" -eq 2 ]
}

Expected behavior
Empty lines in the output should be preserved and no additional empty lines are added.

Environment (please complete the following information):

  • Bats Version: 1.9.0
  • OS: MacOS 13.2.1
  • Bash version: 5.2.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Bash CodeEverything regarding the bash codePriority: CriticalBroken behavior in nearly all environments, e.g. wrong test results, internal bats errorStatus: ConfirmedThe reproducer worked as describedType: Bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions