I know how to run commands and redirect their output, in the context of a shell script. However, I was thinking about doing this inside a custom Mix task. I’ve never done this before and I’m not finding any specific examples in the doc pages I’ve read.
Let’s say that I create Mix.Tasks.Foo and want to invoke the mix xref ... command in the run/1 function. Problem is, I’m not sure how to do this. For example, this looks rather convoluted to me:
def run(_args) do
xref = ["-c", "mix xref ... > my_file.dot"]
System.cmd("sh", xref)
...
end
I assume that I’m missing something really obvious. Clues, anyone?






















