//! Reads lines from the keyboard (fd 0) and echoes them back. "exit" quits. #![no_std] #![no_main] #[macro_use] #[path = "ulib.rs"] mod ulib; fn main() -> i64 { println!("[echo] pid {}: type a line and press Enter", ulib::getpid()); let mut buf = [0u8; 256]; loop { let n = ulib::read(0, &mut buf); // blocks until Enter if n <= 0 { return 1; } let line = core::str::from_utf8(&buf[..n as usize]).unwrap_or("?").trim_end(); println!("[echo] you typed: {}", line); if line == "exit" { return 0; } } }