[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: why did coprocs fd not exist, in this sample submissed on an issue a
From: |
Greg Wooledge |
Subject: |
Re: why did coprocs fd not exist, in this sample submissed on an issue as answer |
Date: |
Thu, 30 Sep 2021 16:02:08 -0400 |
On Thu, Sep 30, 2021 at 09:49:52PM +0200, Alex fxmbsw7 Ratchev wrote:
> i think the middle chapter is the because, sorry i understand your english
> only modestly
> in this case of code i can easily aviod coproc then
> thanks you
You tried to do this:
one=( $( < /proc/fd/$ser ) )
The redirection from /proc/fd/$ser occurs in a subshell, because of the
command substitution $( ). Chet quoted the part of the manual that says
coproc FDs are not available inside subshells.
For anyone who's confused about this: $( ) always forks (creating a
subshell), even if you're using the $(< file) feature as a replacement
for $(cat file).
Maybe you should consider one of these replacements:
read -ra one <&"$ser"
mapfile -t one <&"$ser"
I don't know what your writing process is sending, so you'll have to
choose based on that knowledge. The first one is closest to your
original command.