From 2c4c2e4bb6caa95e73ad5664a2cc5ad263dae280 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Tue, 17 Jun 2014 19:33:53 +0200 Subject: [PATCH 1/3] factor: fix uumain --- factor/factor.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/factor/factor.rs b/factor/factor.rs index 58389de9d..b4db32292 100644 --- a/factor/factor.rs +++ b/factor/factor.rs @@ -64,11 +64,10 @@ fn print_factors_str(num_str: &str) { print_factors(num); } - #[allow(dead_code)] -fn main() { uumain(os::args()); } +fn main() { os::set_exit_status(uumain(os::args())); } -pub fn uumain(args: Vec) { +pub fn uumain(args: Vec) -> int { let program = args.get(0).as_slice(); let opts = [ getopts::optflag("h", "help", "show this help message"), @@ -89,11 +88,11 @@ pub fn uumain(args: Vec) { \n\ {usage}", program = program, version = VERSION, usage = getopts::usage("Print the prime factors of the given number(s). \ If none are specified, read from standard input.", opts)); - return; + return 1; } if matches.opt_present("version") { println!("{} {}", program, VERSION); - return; + return 0; } if matches.free.is_empty() { @@ -105,4 +104,5 @@ pub fn uumain(args: Vec) { print_factors_str(num_str.as_slice()); } } + 0 } From 2aa76c4202ae0a32b2087786fba70606bc8be6e5 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Tue, 17 Jun 2014 19:35:48 +0200 Subject: [PATCH 2/3] tail: fix uumain --- tail/tail.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tail/tail.rs b/tail/tail.rs index a2591c3c8..61132ed7e 100644 --- a/tail/tail.rs +++ b/tail/tail.rs @@ -25,9 +25,9 @@ use std::io::timer::sleep; static PROGRAM: &'static str = "tail"; #[allow(dead_code)] -fn main () { uumain(os::args()); } +fn main() { os::set_exit_status(uumain(os::args())); } -pub fn uumain(args: Vec) { +pub fn uumain(args: Vec) -> int { let mut line_count = 10u; let mut sleep_sec = 1000u64; @@ -51,15 +51,15 @@ pub fn uumain(args: Vec) { Ok (m) => { m } Err(_) => { println!("{:s}", usage(PROGRAM, possible_options)); - return + return 1; } }; if given_options.opt_present("h") { println!("{:s}", usage(PROGRAM, possible_options)); - return; + return 0; } - if given_options.opt_present("V") { version(); return } + if given_options.opt_present("V") { version(); return 0 } let follow = given_options.opt_present("f"); if follow { @@ -112,6 +112,8 @@ pub fn uumain(args: Vec) { tail(&mut buffer, line_count, follow, sleep_sec); } } + + 0 } // It searches for an option in the form of -123123 From 329ac25e07ba2a5b733112862b3a2146d45e3448 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Tue, 17 Jun 2014 19:38:11 +0200 Subject: [PATCH 3/3] uutils: add chroot, factor, nl, tail --- uutils/uutils.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/uutils/uutils.rs b/uutils/uutils.rs index e7949d92b..2d8c8f46c 100644 --- a/uutils/uutils.rs +++ b/uutils/uutils.rs @@ -14,6 +14,7 @@ extern crate getopts; extern crate base64; extern crate basename; extern crate cat; +extern crate chroot; extern crate cksum; extern crate comm; extern crate cp; @@ -21,6 +22,7 @@ extern crate dirname; extern crate du; extern crate echo; extern crate env; +extern crate factor; extern crate fold; extern crate groups; extern crate head; @@ -30,6 +32,7 @@ extern crate id; extern crate kill; extern crate logname; extern crate mkdir; +extern crate nl; extern crate paste; extern crate printenv; extern crate pwd; @@ -39,6 +42,7 @@ extern crate seq; extern crate sleep; extern crate sum; extern crate tac; +extern crate tail; extern crate tee; extern crate touch; extern crate tr; @@ -66,6 +70,7 @@ fn util_map() -> HashMap<&str, fn(Vec) -> int> { map.insert("base64", base64::uumain); map.insert("basename", basename::uumain); map.insert("cat", cat::uumain); + map.insert("chroot", chroot::uumain); map.insert("cksum", cksum::uumain); map.insert("comm", comm::uumain); map.insert("cp", cp::uumain); @@ -73,6 +78,7 @@ fn util_map() -> HashMap<&str, fn(Vec) -> int> { map.insert("du", du::uumain); map.insert("echo", echo::uumain); map.insert("env", env::uumain); + map.insert("factor", factor::uumain); map.insert("false", uufalse); map.insert("fold", fold::uumain); map.insert("groups", groups::uumain); @@ -83,6 +89,7 @@ fn util_map() -> HashMap<&str, fn(Vec) -> int> { map.insert("kill", kill::uumain); map.insert("logname", logname::uumain); map.insert("mkdir", mkdir::uumain); + map.insert("nl", nl::uumain); map.insert("paste", paste::uumain); map.insert("printenv", printenv::uumain); map.insert("pwd", pwd::uumain); @@ -92,6 +99,7 @@ fn util_map() -> HashMap<&str, fn(Vec) -> int> { map.insert("sleep", sleep::uumain); map.insert("sum", sum::uumain); map.insert("tac", tac::uumain); + map.insert("tail", tail::uumain); map.insert("tee", tee::uumain); map.insert("touch", touch::uumain); map.insert("tr", tr::uumain);