This commit is contained in:
Christoph J. Scherr 2024-02-21 14:15:46 +01:00
parent f6f91e5201
commit 5182cb446d
Signed by: cscherrNT
GPG Key ID: 8E2B45BC51A27EA7
1 changed files with 3 additions and 1 deletions

View File

@ -9,13 +9,15 @@ fn main() -> Result<(), io::Error> {
.read(false)
// try to use $TTY set by the terminal, otherwise use the default tty
.open(std::env::var("TTY").unwrap_or(String::from(TTY)))
.inspect_err(|err| eprintln!("{err}"))?;
.inspect_err(|err| eprintln!("could not open tty: {err}"))?;
// we want to write to the stdout too
let mut stdout = io::stdout();
// sadly, we need to store the content of `stdin` in a buffer and cannot just `io::copy()` it
// multiple times. `tee` from the GNU coreutils does this too.
let mut buf = Vec::new();
io::stdin()
// FIXME: we don't want to always read to end! If we want to seep a network socket for
// example.
.read_to_end(&mut buf)
.inspect_err(|err| eprintln!("{err}"))?;