| Deutsch English Français Italiano |
|
<vf0en1$3tngr$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.unix.shell
Subject: Re: coproc or whatever in bash and ksh (Was: Different variable
assignments)
Date: Sat, 19 Oct 2024 16:11:44 +0200
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <vf0en1$3tngr$1@dont-email.me>
References: <lmt83dFsvbvU3@mid.individual.net> <vec3qb$3q4ms$3@dont-email.me>
<vf064q$3dhev$1@news.xmission.com> <vf0a1h$3sn0s$1@dont-email.me>
<vf0cjv$3djd7$1@news.xmission.com> <vf0dn6$3t9fe$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Oct 2024 16:11:46 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f0860b4b4247e4e0a1ca74c8e135d78d";
logging-data="4120091"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+O+gJsdT/4ECQVFPHsT0KX"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:51lqDsiZq2e0CU/oStwYjjtHCLM=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <vf0dn6$3t9fe$1@dont-email.me>
Bytes: 2344
On 19.10.2024 15:54, Janis Papanagnou wrote:
>>>> Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>>>>
>>>>> coproc { uname -sr; }
>>>>> read -u ${COPROC[0]} var3
>>>>> wait $COPROC_PID
>>>>> echo $var3
>>>>
>
> The syntax for the [unnecessary] co-process application depicted
> above would in Ksh be
>
> uname -sr |&
> read -p var
> echo "$var"
Concerning the syntax (differences, and generally) I want to add
that it's worthwhile to compare the Ksh syntax with the approach
that we would typically take [in Ksh] to solve the task
uname -sr | read var
echo "$var"
We see that the co-process syntax is a straightforward variant of
the ordinary piping. (As opposed to bash that introduces a lot of
[bulky] stuff that's not even resembling in any way the read-pipe.)
For the interested folks let me hijack my post to add that it's
possible to redirect the co-processes to other file descriptors
(using <&p and >&p with appropriate file descriptor numbers) so
that multiple co-processes can be simultaneously used.
Janis