[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

questions about coproc

From: Britton Kerin
Subject: questions about coproc
Date: Thu, 9 Mar 2023 09:47:58 -0900

First let me say coproc is quite nifty, thanks for implementing!

One thing I've done is make a small regex server for bash using perl:

coproc perl_regex_server {
  perl <(cat <<'  END_PERL'
    use strict; use warnings;
    $| = 1;
    while ( 1 ) {
      my $rex = <>;
      my $str = <>;
      if ( $str =~ m/$rex/ ) {
        # FIXME: Sadly this die argument doesn't show anywhere:
        defined($1) or die 'group $1 unexpectedly undefined';
        print length($1);
      print "\n";

It works great for my intended purpose (smarter word movement for, with the only issues being:

1.  no obvious way to propagate e.g. the die argument in the above
back to the controlling terminal.  Is there some easy way to do this
that I missed?

2.  If the above job has been created from e.g. ~/.bashrc, then when I
try to make another coproc I get an error like this on the terminal:

     bash: warning: execute_coproc: coproc [11142:perl_regex_server]
still exists

The new coproc seems to exist and work, but this error is worrisome
and would be very confusing to a user who wasn't aware of this coproc.

3.  I don't really like seeing it as a job in job control.  I wonder
if it might be appropriate to have an option to hide from the job
control list, or hide unless some option to jobs is given.  It's isn't
like other jobs and can't really be controlled in the same way.  Or
maybe it could be in it's own section of the list and not take up job
number 1 or something.  Thoughts?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]