help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Creating an anonymous pipe for later use


From: Bob Proulx
Subject: Re: [Help-bash] Creating an anonymous pipe for later use
Date: Mon, 13 Oct 2014 20:49:17 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

Russell Lewis wrote:
> It is clear that you are a far more experienced shell programmer than I - I
> have no doubt that your code is far better than mine.  But doesn't it sort
> of illustrate the point why it would be nice to create anonymous pipes in a
> shell script?  That wouldn't eliminate all of the complexity, of course, but
> it would reduce some of it.

If I gave the impression that I was arguing against bash having named
anonymous pipes I did not intend to do so.  Obviously anonymous pipes
is what makes cmd1 | cmd2 so attractive.  Because it is trivially easy
to use.  I started out simply digging a little deeper into one of your
comments and it went from there.  Not a reflection upon your original
suggestion.

>> I'm hoping for some sort of command (I'll call it "pipe" in this
>> email) which would call pipe(), and then assign the two file
>> descriptors to variables.
>> This would allow syntax like the following:
>>     pipe {read_end} {write_end}
>>     cmd1 >${write_end} &
>>     cmd2 <${read_end}  &
>>     exec -<${write_end}
>>     exec -<${read_end}

At the current time bash does not have the feature natively to create
anonymous pipes for later use as you suggest above where they are
tagged in some way that can be referred to and used later.  If someone
were to propose the code to implement such a thing in the shell I
could see it having uses.  It would be hard to think through however.
I have no idea what Chet or the others would think of it.

But I am not sure the need is specifically about pipes.  I think it is
about cleanup of artifacts created for the internal use of the script.
Because as you note you can create named pipes.  They just need to be
cleaned up afterward.  For me the devil of details is to make sure
that the created objects are cleaned up afterward.

> Not that I'm complaining.  I've used bash for years, and love it. But one
> can always wish for the "one more feature." :)

I am rather the opposite.  I often vote on the side against creeping
featurism.  Because often it is the rule of unintended consequences
that causes problems in things that are related but the originator
didn't realize was connected.  And yet I do use a lot of new features.
I am not always a Luddite concerning these things.  It just seems that
way from an external point of view.  :-)

Bob



reply via email to

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