On 22/11/2023 19:17, Greg Wooledge wrote:
On Wed, Nov 22, 2023 at 07:06:58PM +0700, Max Nikulin wrote:

    ssh localhost echo remote
    echo local

This is like <https://mywiki.wooledge.org/BashFAQ/089>.  ssh grabs
all of the stdin (until EOF) and leaves none for bash.

Thanks. I expected to find it among pitfalls.

I don't know dash's internals.  Maybe dash reads an entire buffer's
worth of stdin at a time, instead of a command at a time as bash does.

It seems dash reads a block from stdin (and does not lseek back even for regular files) only for commands. I do not see significant difference when commands reading stdin are placed into a script

cmd='seq 1000000 | while read -r var ; do
  printf "%s\n" "$var" ;
  ssh localhost echo remote ;
done'
bash -c "$cmd"
dash -c "$cmd"

If the script is passed as an argument, not to stdin, then output contains
"local" in both cases.

Yes.  In that case, bash is not competing with ssh for stdin.

I have found an attempt to report it:

https://lore.kernel.org/dash/6640a8ee-eda0-1e35-df1a-c8b303440...@mail.de/
stdin should be consumed line by line. Fri, 22 Oct 2021 13:11:43 +0200

No response.

Reply via email to