Skip to content

mapfile -t bugs #2287

Open
Open
@andychu

Description

@andychu

from #1069

58. BUG: mapfile -t stops reading the input with an empty line

$ bash -c 'mapfile -t lines; declare -p lines' <<< $'hello\n\nworld'
declare -a lines=([0]="hello" [1]="" [2]="world")
$ osh -c 'mapfile -t lines; declare -p lines' <<< $'hello\n\nworld'
declare -a lines=(hello)
Also, it doesn't preserve the initial empty line or the ending newline.

$ bash -c 'mapfile -t lines; declare -p lines' <<< $'\nhello'
declare -a lines=([0]="" [1]="hello")
$ bash -c 'mapfile -t lines; declare -p lines' <<< $'hello\n'
declare -a lines=([0]="hello" [1]="")
$ osh -c 'mapfile -t lines; declare -p lines' <<< $'\nhello'
declare -a lines=()
$ osh -c 'mapfile -t lines; declare -p lines' <<< $'hello\n'
declare -a lines=(hello)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions