rune-rs / rune

An embeddable dynamic programming language for Rust.
https://rune-rs.github.io
Apache License 2.0
1.7k stars 85 forks source link

Output capture on process in rune-modules is non-functional #751

Open VorpalBlade opened 1 month ago

VorpalBlade commented 1 month ago

Consider this rune code using process from rune-modules:

    let cmd = process::Command::new("ls");
    cmd.arg("-l");
    dbg(cmd);
    let child = cmd.spawn()?;
    dbg(child);
    let output = child.wait_with_output().await?;
    std::io::dbg!("output:", output.stdout);

It will print:

<Command object at 0x7ffceb01aba8>
<Child object at 0x7ffceb01aba8>

[ output of ls -l here ]

"output:"
[]

As can be seen, the output is not captured, but just sent straight to stdout/stderr. There is also no function in the API of process to enable capturing.

So the API seems a bit broken / untested?

udoprog commented 1 month ago

The documentation is lacking and there is like you say no support for configuring piped output.

Here's the documentation of the component it's based of, which Monica the behavior of std: https://docs.rs/tokio/latest/tokio/process/struct.Child.html#method.wait_with_output

I would be happy if someone wanted to adopt these modules, cause I only use them for reference of how certain things are done and add any "std things" which I've ended up using!

VorpalBlade commented 1 month ago

I have a need for a more fully featured process module in general. In particular I need to be able to create a pipeline of several child processes (kind of like duct except that is not async).

Not sure how to do that with tokio (does it work the same way as with normal std?).

I could definitely look into this, but I have no way of testing on platforms other than Linux (and possibly other free nixes in VMs). Also, don't expect any time frames.