soenkehahn / cradle

Rust library for running child processes
Creative Commons Zero v1.0 Universal
38 stars 5 forks source link

Add ability to run commands that require access to TTY #194

Open casey opened 3 years ago

casey commented 3 years ago

I tried to do:

run!(%"systemctl edit foo");

Which didn't work, because systemctl edit foo requires a TTY, because cradle always uses command.stdin(Stdio::piped()), the process doesn't inherit the TTY on standard input.

There should probably be some way to tell cradle that commands should inherit standard input.

casey commented 3 years ago

@soenkehahn This seems like something we should support, but I wanted to check with before I started implementing it.

I was thinking about how to test this, and the obvious thing to do is pipe data into a binary that uses cradle to read standard input and print it to standard output. (I don't think there's a way to test this from within a unit test.) I was thinking of doing this with a test helper subcommand, since that binary already exists:

"cat using cradle" => {
  run!("cat");
}

I could also do it with a separate binary, maybe called cradle_cat. Which do you think is better?