//! rm path... -- delete files, and empty directories (shell alias: del). //! (Real rm needs -r for directories; this one just tries rmdir.) #![no_std] #![no_main] #[macro_use] #[path = "ulib.rs"] mod ulib; use ulib::*; fn main() -> i64 { if argc() < 2 { eprintln!("usage: rm path..."); return 2; } let mut status = 0; for i in 1..argc() { let path = arg(i).unwrap_or(""); let mut r = unlink(path); if r == -EISDIR { r = rmdir(path); // fails with ENOTEMPTY if there's something in it } if r < 0 { eprintln!("rm: {}: {}", path, strerror(r)); status = 1; } } status }