#[cfg(unix)]
fn main() -> std::io::Result<()> {
use std::io::Read;
use std::io::Write;
use std::io::BufReader;
use teletypewriter::{create_pty_with_fork, ProcessReadWrite, Pty};
let mut process: Pty = create_pty_with_fork(Some("bash"), &[], 80, 25, 0, 0)?;
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() {}