#[cfg(unix)]
fn main() -> std::io::Result<()> {
use std::borrow::Cow;
use std::io::Read;
use std::io::Write;
use std::io::BufReader;
use teletypewriter::{create_pty_with_fork, ProcessReadWrite, Pty};
let shell = Cow::Borrowed("bash");
let mut process: Pty = create_pty_with_fork(&shell, 80, 25)?;
process.writer().write_all(b"1").unwrap();
process.writer().write_all(b"2").unwrap();
process.writer().write_all(b"ls\n").unwrap();
process.writer().write_all(b"echo 1\n").unwrap();
let reader = BufReader::new(process);
for bs in reader.bytes() {
let u = [bs.unwrap()];
println!("{:?}", String::from_utf8_lossy(&u));
}
Ok(())
}
#[cfg(not(unix))]
fn main() {}