andrewchambers/janetsh

Garbage collected redirectable pipes + function to make pipes.

andrewchambers opened this issue · 1 comments

I think something like:

(let [[a b] (sh/pipes)] ($ ls > [a] &) ($ cat < [b]))

I imagine a macro (name tbd):

($ cat < (sh/$-pipe ls )))

could be shorthand for:

($ cat <(let [[a b] (sh/pipes)] ($ ls > a &) b) )

I think this API is enough to let users do some interesting things.

To enable it we need a new pipe abstract type, some functions:

(sh/pipes) (sh/close-pipe p)

Questions:

Does the parent side of a pipe get closed automatically when used in a redirect? It seems necessary to me.

Implemented, waiting on an upstream patch.