I am trying to create a function that installs homebrew by running install.sh
using std::process::Command
:
let output = Command::new("bash")
.arg("install.sh")
.output()
.expect("brew install failed");
println!("command output: {:?}", output);
This prints the following output, which is a prompt asking for the user's password, in this case mine.
command output: "==> Checking for `sudo` access (which may request your password).\nNeed sudo access on macOS (e.g. the user blah needs to be an Administrator)!\n"
How do I pass in the password to the command and continue with the installation? Basically, I am looking for a way to emulate the shell script's expect
function using the Command
struct. Is it possible?