bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mapfile doesn't accept input from a pipe


From: Keith Thompson
Subject: mapfile doesn't accept input from a pipe
Date: Wed, 28 Jun 2017 19:08:27 -0700

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux bomb20 4.8.0-46-generic #49-Ubuntu SMP Fri Mar 31
13:57:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: maint

Description:
        The "mapfile" command works correctly if stdin is redirected
from a file, but not if it's from a pipe.
        Demonstrated with several versions including the latest
bash-snap-20170626

Repeat-By:
        This script demonstrates the problem:
        __CUT_HERE__
        #!/bin/bash

        printf 'one\ntwo\nthree\n' > /tmp/input.txt

        mapfile REDIRECT < /tmp/input.txt
        cat /tmp/input.txt | mapfile PIPE

        echo "\$REDIRECT has address@hidden elements"
        echo "\$PIPE     has address@hidden elements"

        if [ address@hidden -eq 3 ] && [ address@hidden -eq 3 ] ; then
            echo PASS
            exit 0
        else
            echo FAIL
            exit 1
        fi
        __AND_HERE__



reply via email to

[Prev in Thread] Current Thread [Next in Thread]