BASH: Does it (or will it) support co-processes?

BASH: Does it (or will it) support co-processes?

Post by Jeremy Mathe » Mon, 04 May 1998 04:00:00



On my HP/UX system, the "Posix Shell" supports a nifty little thing called
co-processes.  With this, you can spawn a process with "&|" (instead of the
usual "&") and then you can send and recieve data from the spawned process
via its stdin/stdout.  It is a generalized version of the usual piping
operation.  However, bash (at least the versions I have checked, on various
Linux machines) does not have this feature and I was wondering if it
was planned for inclusion in a later version?

Note: ksh (pdksh on my Linux box) has the feature; I think it did originate
with ksh.

************************************************************************
In case of atomic attack, the federal ruling against prayer in schools
will be temporarily canceled.


          hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer

 
 
 

BASH: Does it (or will it) support co-processes?

Post by Brian McCaule » Wed, 06 May 1998 04:00:00



> On my HP/UX system, the "Posix Shell" supports a nifty little thing called
> co-processes.  With this, you can spawn a process with "&|" (instead of the
> usual "&") and then you can send and recieve data from the spawned process
> via its stdin/stdout.  It is a generalized version of the usual piping
> operation.  However, bash (at least the versions I have checked, on various
> Linux machines) does not have this feature and I was wondering if it
> was planned for inclusion in a later version?

From the Bash FAQ:

21) Now that I've converted from ksh to bash, are there equivalents to
    ksh features like autoloaded functions and the `whence' command?

There are features in ksh-88 that do not have direct bash equivalents.
Most, however, can be emulated with very little trouble.

ksh-88 feature          Bash equivalent
--------------          ---------------
[[...]]                 can usually use [...]; minor differences (no
                        pattern matching, for one)
compiled-in aliases     set up aliases in .bashrc; some ksh aliases
are
                        bash builtins (hash, history, type)
$(<file)             $(cat file)
extended patterns       no good substitute
coprocesses             named pipe pairs (one for read, one for write)
typeset +f              declare -F
cd, print, whence       function substitutes in
examples/functions/kshenv
autoloaded functions    examples/functions/autoload is the same as
typeset -fu
read var?prompt         read -p prompt var

--

 .  _\\__[oo       from       | Phones: +44 121 471 3789 (home)

.  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
 # ll  l\\  ~~~~ ~   ~ ~    ~ | http://wcl-l.bham.ac.uk/~bam/


 
 
 

BASH: Does it (or will it) support co-processes?

Post by Jeremy Mathe » Wed, 06 May 1998 04:00:00




about co-processes in bash:

Quote:

>From the Bash FAQ:

>21) Now that I've converted from ksh to bash, are there equivalents to
>    ksh features like autoloaded functions and the `whence' command?

>There are features in ksh-88 that do not have direct bash equivalents.
>Most, however, can be emulated with very little trouble.

>ksh-88 feature              Bash equivalent
>--------------              ---------------
>[[...]]                     can usually use [...]; minor differences (no
>                    pattern matching, for one)
>compiled-in aliases set up aliases in .bashrc; some ksh aliases
>are
>                    bash builtins (hash, history, type)
>$(<file)         $(cat file)
>extended patterns   no good substitute
>coprocesses         named pipe pairs (one for read, one for write)

OK, so the answer to "Are they planning to do it?" is "Probably not."
My initial feeling about using named pipes is that it could get ugly; it
adds an additional layer of management (I have to create the named pipes at
start [ensuring uniqueness], remove them when done, and worry about
leaving them behind if my script crashes).  Not that any of this is
particularly hard, but it does add an additional layer.

Anyway, does the Bash FAQ give (or could you give) the specific syntax for
emulating &| with named pipes?

************************************************************************
A: Northern Exposure and Microsoft Windows.

Q: Name two flakey things produced in Redmond, WA.


          hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer

 
 
 

BASH: Does it (or will it) support co-processes?

Post by Christian Weisgerb » Thu, 07 May 1998 04:00:00




> ksh-88 feature     Bash equivalent
> --------------     ---------------
> [[...]]            can usually use [...]; minor differences (no
>                    pattern matching, for one)
> $(<file)                $(cat file)
> extended patterns  no good substitute

Note that these are now directly supported in bash 2.02.

--

  See another pointless homepage at <URL:http://home.pages.de/~naddy/>.

 
 
 

1. co-processes and bash (ksh does it, can bash?)

Ksh supports the concept of a co-process. You can start a process in
the background with it's stdin and stdout connected to the shell. You
do this by putting the |& operator after the command. You can then use
read -p to read from the co-process and print -p to write to it.

I don't see any mention of this nice feature in the BASH
documentation.

Is there any plan to support this in the future?

Is there some other, more general procedure, by which this same
feature could be accomplished?

-Larry

2. tycoon

3. It`s IMPORTANT!!!

4. ULTRIX-11 question

5. Please Help....it′s a very small thing!!!!.PLEASE

6. Alpha peripherals for the SROM port?

7. Help me !!!!!! I have no Idea it′s crucial

8. What does fsflush exactly do ?

9. It`s IMPORTANT!!!

10. BASH BASH BASH BASH BASH BASH BASH BASH BASH BASH

11. Co-processes in Kornshell

12. cant feed passwd to startssl script using ksh co-processes

13. Co-Processes