cat.ha (501B)
1 use fmt; 2 use io; 3 use os; 4 use strings; 5 use fs; 6 7 use util; 8 9 fn print(h: io::handle) void = { 10 let b: []u8 = [0]; 11 12 for (let i = 0z; true; i += 1) { 13 match (io::read(h, b)) { 14 case size => fmt::print(b[0]: rune)!; 15 case => break; 16 }; 17 }; 18 }; 19 20 export fn main() void = { 21 for (let f .. os::args[1..]) { 22 io::close(match(os::open(f)) { 23 case let f: io::file => print(f); yield f; 24 case let e: fs::error => util::die(fs::strerror(e), f); 25 } 26 )!; 27 }; 28 29 if (len(os::args) == 1) 30 print(os::stdin); 31 };