![](/static/253f0d9b/assets/icons/icon-96x96.png)
![](https://programming.dev/pictrs/image/170721ad-9010-470f-a4a4-ead95f51f13b.png)
31·
10 months agouse std::process::Command;
fn main() {
Command::new("sh")
.arg("-c")
.arg("echo Hello World!")
.spawn()
.unwrap();
}
Like this?
use std::process::Command;
fn main() {
Command::new("sh")
.arg("-c")
.arg("echo Hello World!")
.spawn()
.unwrap();
}
Like this?
Yes and no. While coreutils does provide an
echo
binary, shells also have a built-in for optimisation purposes.At first I had the code calling the binary directly, but then changed it to spawning a shell (and so using the builtin). It’s very cursed either way.