it does not work actually
cargo devel CI / cargo CI (push) Failing after 22s Details

This commit is contained in:
Christoph J. Scherr 2024-02-21 13:18:22 +01:00
parent f0765004b7
commit bec7203240
Signed by: cscherrNT
GPG Key ID: 8E2B45BC51A27EA7
2 changed files with 11 additions and 4 deletions

View File

@ -1,12 +1,15 @@
use std::io::{self, prelude::*};
fn main() -> Result<(), io::Error> {
// TODO: check if stdin is empty and show usage
let mut tty = std::fs::File::options()
.write(true)
.read(false)
.open("/dev/tty")?;
io::copy(&mut io::stdin(), &mut tty)?;
tty.flush()?;
io::copy(&mut io::stdin(), &mut io::stdout())?;
.open("/dev/tty")
.inspect_err(|err| eprintln!("{err}"))?;
// FIXME: only works with cargo run?
io::copy(&mut io::stdin(), &mut tty).inspect_err(|err| eprintln!("{err}"))?;
tty.flush().inspect_err(|err| eprintln!("{err}"))?;
io::copy(&mut io::stdin(), &mut io::stdout()).inspect_err(|err| eprintln!("{err}"))?;
Ok(())
}

4
tests/cli.rs Normal file
View File

@ -0,0 +1,4 @@
#[test]
fn pipe_echo_cat() {
todo!()
}