Closed frenchy64 closed 5 years ago
Here is a proposed solution.
(with-script-context [:default]
(script
(~with-redir [[:err :out]
[:out "file.txt" :append true]
[:err "err.txt"]
[[:out :err] "/dev/null"]]
(echo "asfd")
(echo "asfd")
(echo "asfd"))))
=>
{
echo "asdf"
echo "asdf"
echo "asdf"
} 1>&2 >>file.txt 2>err.txt &>/dev/null
How do pipes work ? echo "asdf" | something . with-redir can take a :pipe keyword
Pipes are already in stevedore.
(with-script-context [:default]
(script
(pipe (echo "asfd")
(grep "a")
(echo))))
=>
echo asfd | grep a | echo
Does it make sense to keep the distinction between pipes and IO redirection?
Makes sense. with-redir is quite an useful macro to have
I would name it with-redirect
Bash has plenty of IO redirection commands like < and <&-.
These could possibly be mapped to commands as such:
A comparison to Windows IO redirection commands should also be made to try and create a set of stevedore scripts for both OS's.