Re: stdin should be consumed line by line

Max Nikulin
2024-06-30T05:11:20Z

On 22/10/2021 18:11, Tycho Kirchner wrote:
> I think stdin should be consumed line by line in order to make passing
> to other commands possible. Please consider the following difference
> between the stdin "consumption" between bash and dash
>
> $ stdintest(){ printf 'echo one\ndash -c "while read -r row; do echo got
> row \$row; done" \necho two\n'; }
> $ stdintest | dash
> one
> two
> $ stdintest | bash
> one
> got row echo two
> $
>
> I think bash behaves "correct" here.

When I noticed the issue, I found this message with no response, but not
other threads. I believe, the following links may be useful for those
who will get this report in search engine results. It is a bug in dash
and latest released version does not contains its fix.

<https://lore.kernel.org/dash/20221213221732.6mvv22u7ktdozrbx@tarta.nabijaczleweli.xyz/t/>
[PATCH] input: preadfd: read standard input byte-wise
Tue, 13 Dec 2022 23:17:32 +0100

<https://lore.kernel.org/dash/cover.1717291846.git.herbert@gondor.apana.org.au/t/#u>
[v3 PATCH 0/3] Improve performance when reading stdin.
Sun, 02 Jun 2024 09:31:30 +0800

<https://bugs.debian.org/862907>
dash: Incorrectly slurps script from stdin (POSIX compliance issue)