andrewchambers / janetsh

A powerful new shell that uses the janet programming language for both the implementation and repl.
https://janet-shell.org
MIT License
372 stars 13 forks source link

Garbage collected redirectable pipes + function to make pipes. #205

Closed andrewchambers closed 5 years ago

andrewchambers commented 5 years ago

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.

andrewchambers commented 5 years ago

Implemented, waiting on an upstream patch.