Open StefanKarpinski opened 7 years ago
What about a new method for |>
?
|>(a::Cmd, b::Cmd) = pipeline(a, b)
Been there, done that. tl;dr: |>
does not generalize well to all the kinds of redirection one needs for command pipelines – giving this monster a bit of syntax only makes it hungry for more, all of which is pretty badly punny. Using standard shell syntax inside of backticks makes using syntax unproblematic since it confines the scope of its meaning to the context of backticks.
Implement the following kinds of constructions in backticks using standard shell syntax:
`grep foo /usr/share/dict/words | wc -l`
=>pipeline(`grep foo /usr/share/dict/words`, `wc -l`)
`echo hello > file.txt`
=>pipeline(`echo hello`, "file.txt")
, including append mode with>>
, input with<
, etc.{ }
:`{a,b}.{c,d}`
=>`a.c a.d b.c b.d`
This stuff is all currently possible, but the API for it is a bit hard to remember. This will effectively implement a portable shell-like language inside of backticks, which translates to a Julia implementation backed by libuv. It avoids most of the complexity of shells as languages since it's embedded in a full-fledged programming language (Julia).