Sujet : Re: coprocs - again (Was: Different variable assignments)
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.unix.shellDate : 25. Oct 2024, 05:26:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vff6l8$31j2u$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 20.10.2024 11:12, Kenny McCormack wrote:
In article <vf239t$9ikn$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>
I don't think it makes much sense to discuss subjective valuations.
But okay.
It has to do with certain habits/conventions that Usenet posters have
fallen into. [...]
Okay.
[...]
No comment on the rest, other than to say that you seem to claim that ksh
does support multiple concurrent coprocs, which I think is wrong, [...]
I meant that you can have several asynchroneous processes started
which are each connected to the same main shell session with pipes
for communicating. For that you have to redirect the default pipe
channels because there's of course just one option '-p' with the
commands 'read' and 'print' and you need some way to differentiate
the various channels. I just hacked a sample to show what I mean...
bc |&
exec 3<&p 4>&p
bc -l |&
exec 5<&p 6>&p
while IFS= read -r line
do
case ${line} in
(*[.]*)
print -u6 "$line"
read -u5 res
print "Res(R): $res"
;;
(*)
print -u4 "$line"
read -u3 res
print "Res(I): $res"
;;
esac
done
(The second 'exec' isn't necessary for the last started coprocess
since you can use options '-p' as with a single coprocess instead
of the -u5 and -u6, but you see that there's in principle arbitrary
numbers of coprocesses possible.)
Janis