diff --git a/Makefile b/Makefile index 34733f74d..fbba2f130 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,9 @@ BUILD ?= $(PROGS) EXES := \ $(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS)))) +CRATES := \ + $(sort $(filter $(EXES), $(filter-out md5sum, $(EXES)))) + # Programs with usable tests TEST_PROGS := \ cat \ @@ -89,6 +92,11 @@ clean_$(1): endif endef +define CRATE_BUILD +build/$(2): $(1)/$(1).rs + $(call command,$(RUSTC) $(RUSTCFLAGS) --crate-type rlib $(1)/$(1).rs --out-dir build) +endef + # Test exe built rules define TEST_BUILD test_$(1): tmp/$(1)_test build build/$(1) @@ -99,7 +107,14 @@ tmp/$(1)_test: $(1)/test.rs endef # Main rules +ifneq ($(MULTICALL), 1) all: build $(EXES_PATHS) +else +all: build build/uutils + +build/uutils: uutils/uutils.rs $(addprefix build/, $(foreach crate,$(CRATES),$(shell $(RUSTC) --crate-type rlib --crate-file-name $(crate)/$(crate).rs))) + $(RUSTC) $(RUSTCFLAGS) -L build/ uutils/uutils.rs -o $@ +endif test: tmp $(addprefix test_,$(TESTS)) $(RM) -rf tmp @@ -117,5 +132,8 @@ tmp: # Creating necessary rules for each targets $(foreach exe,$(EXES),$(eval $(call EXE_BUILD,$(exe)))) $(foreach test,$(TESTS),$(eval $(call TEST_BUILD,$(test)))) +ifeq ($(MULTICALL), 1) +$(foreach crate,$(CRATES),$(eval $(call CRATE_BUILD,$(crate),$(shell $(RUSTC) --crate-type rlib --crate-file-name --out-dir build $(crate)/$(crate).rs)))) +endif .PHONY: all test clean diff --git a/base64/base64.rs b/base64/base64.rs index 2dc8c9188..a98d81676 100644 --- a/base64/base64.rs +++ b/base64/base64.rs @@ -35,8 +35,7 @@ mod util; static NAME: &'static str = "base64"; -fn main() { - let args = os::args(); +pub fn uumain(args: Vec) { let opts = ~[ optflag("d", "decode", "decode data"), optflag("i", "ignore-garbage", "when decoding, ignore non-alphabetic characters"), @@ -91,6 +90,10 @@ fn main() { } } +fn main() { + uumain(os::args()); +} + fn decode(input: &mut Reader, ignore_garbage: bool) { let mut to_decode = match input.read_to_str() { Ok(m) => m, diff --git a/basename/basename.rs b/basename/basename.rs index c3364ae9f..f60a6ace7 100644 --- a/basename/basename.rs +++ b/basename/basename.rs @@ -23,8 +23,9 @@ mod util; static NAME: &'static str = "basename"; static VERSION: &'static str = "1.0.0"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = strip_dir(args.get(0).as_slice()); // diff --git a/cat/cat.rs b/cat/cat.rs index ca269ab8f..46ced03a3 100644 --- a/cat/cat.rs +++ b/cat/cat.rs @@ -19,8 +19,9 @@ use std::io::{print, File}; use std::io::stdio::{stdout_raw, stdin_raw}; use std::io::{BufferedWriter}; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).as_slice(); let opts = ~[ getopts::optflag("A", "show-all", "equivalent to -vET"), diff --git a/cksum/cksum.rs b/cksum/cksum.rs index b7fc3da5c..bb4d94bfe 100644 --- a/cksum/cksum.rs +++ b/cksum/cksum.rs @@ -77,8 +77,9 @@ fn open_file(name: &str) -> IoResult> { } } -pub fn main() { - let args = os::args(); +pub fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let opts = [ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), diff --git a/comm/comm.rs b/comm/comm.rs index 43d3eaa07..b9e2e2f50 100644 --- a/comm/comm.rs +++ b/comm/comm.rs @@ -87,8 +87,9 @@ fn open_file(name: &str) -> IoResult> { } } -pub fn main() { - let args = os::args(); +pub fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let opts = [ getopts::optflag("1", "", "suppress column 1 (lines uniq to FILE1)"), getopts::optflag("2", "", "suppress column 2 (lines uniq to FILE2)"), diff --git a/cp/cp.rs b/cp/cp.rs index af0c35e5f..074c0e822 100644 --- a/cp/cp.rs +++ b/cp/cp.rs @@ -31,8 +31,9 @@ pub enum Mode { Version, } -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let opts = ~[ optflag("h", "help", "display this help and exit"), optflag("", "version", "output version information and exit"), diff --git a/dirname/dirname.rs b/dirname/dirname.rs index 11df43cab..8ae72da43 100644 --- a/dirname/dirname.rs +++ b/dirname/dirname.rs @@ -16,8 +16,9 @@ use std::io::print; static VERSION: &'static str = "1.0.0"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ getopts::optflag("z", "zero", "separate output with NUL rather than newline"), diff --git a/du/du.rs b/du/du.rs index a27fa07ca..bc897f033 100644 --- a/du/du.rs +++ b/du/du.rs @@ -90,8 +90,9 @@ fn du(path: &Path, mut my_stat: Stat, return stats; } -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).as_slice(); let opts = ~[ // In task diff --git a/echo/echo.rs b/echo/echo.rs index 17da759a3..caa49bf9c 100644 --- a/echo/echo.rs +++ b/echo/echo.rs @@ -69,8 +69,9 @@ fn convert_str(string: &str, index: uint, base: uint) -> (char, int) { return (to_char(&bytes, base), max_digits) } -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ getopts::optflag("n", "", "do not output the trailing newline"), diff --git a/env/env.rs b/env/env.rs index 946eaebcd..15a352248 100644 --- a/env/env.rs +++ b/env/env.rs @@ -13,6 +13,8 @@ #![allow(non_camel_case_types)] +use std::os; + struct options { ignore_env: bool, null: bool, @@ -51,8 +53,9 @@ fn print_env(null: bool) { } } -fn main() { - let args = std::os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let prog = args.get(0).as_slice(); // to handle arguments the same way than GNU env, we can't use getopts diff --git a/fold/fold.rs b/fold/fold.rs index 7ab19ae21..2adfffbbf 100644 --- a/fold/fold.rs +++ b/fold/fold.rs @@ -26,9 +26,10 @@ mod util; static NAME: &'static str = "fold"; static VERSION: &'static str = "1.0.0"; -fn main() { +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { - let args = os::args(); let (args, obs_width) = handle_obsolete(args.as_slice()); let program = args.get(0).clone(); diff --git a/groups/groups.rs b/groups/groups.rs index d46ac19d1..2b2c103db 100644 --- a/groups/groups.rs +++ b/groups/groups.rs @@ -25,8 +25,9 @@ use c_types::{get_pw_from_args, group}; static NAME: &'static str = "groups"; -fn main () { - let args = os::args(); +fn main () { uumain(os::args()); } + +pub fn uumain(args: Vec) { let options = [ optflag("h", "", "Help") ]; diff --git a/head/head.rs b/head/head.rs index 150732bd5..e4bbec498 100644 --- a/head/head.rs +++ b/head/head.rs @@ -22,11 +22,13 @@ use getopts::{optopt, optflag, getopts, usage}; static PROGRAM: &'static str = "head"; -fn main () { +fn main () { uumain(os::args()); } + +pub fn uumain(args: Vec) { let mut line_count = 10u; // handle obsolete -number syntax - let options = match obsolete(os::args().tail()) { + let options = match obsolete(args.tail()) { (args, Some(n)) => { line_count = n; args }, (args, None) => args }; diff --git a/hostid/hostid.rs b/hostid/hostid.rs index 122a2aa05..b05f4d287 100644 --- a/hostid/hostid.rs +++ b/hostid/hostid.rs @@ -49,8 +49,9 @@ extern { pub fn gethostid() -> c_long; } -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let opts = [ optflag("", "help", "display this help and exit"), diff --git a/hostname/hostname.rs b/hostname/hostname.rs index 05929c130..af7ec2aaf 100644 --- a/hostname/hostname.rs +++ b/hostname/hostname.rs @@ -23,8 +23,9 @@ extern { fn sethostname(name: *libc::c_char, namelen: libc::c_int) -> libc::c_int; } -fn main () { - let args = os::args(); +fn main () { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0); let options = [ diff --git a/id/id.rs b/id/id.rs index 3ec427975..3d60d7776 100644 --- a/id/id.rs +++ b/id/id.rs @@ -87,8 +87,9 @@ extern { static NAME: &'static str = "id"; -fn main () { - let args = os::args(); +fn main () { uumain(os::args()); } + +pub fn uumain(args: Vec) { let args_t = args.tail(); let options = [ diff --git a/kill/kill.rs b/kill/kill.rs index ac9fa2591..a8fa7ec67 100644 --- a/kill/kill.rs +++ b/kill/kill.rs @@ -53,8 +53,9 @@ pub enum Mode { } -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let opts = ~[ optflag("h", "help", "display this help and exit"), diff --git a/logname/logname.rs b/logname/logname.rs index d6b36219a..1149ae8dd 100644 --- a/logname/logname.rs +++ b/logname/logname.rs @@ -43,8 +43,9 @@ fn version() { println!("{} {}", NAME, VERSION); } -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); // diff --git a/mkdir/mkdir.rs b/mkdir/mkdir.rs index 7f56bb69d..28956a89d 100644 --- a/mkdir/mkdir.rs +++ b/mkdir/mkdir.rs @@ -28,8 +28,9 @@ static VERSION: &'static str = "1.0.0"; /** * Handles option parsing */ -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let opts = ~[ // Linux-specific options, not implemented diff --git a/paste/paste.rs b/paste/paste.rs index e76143234..a8556aef9 100644 --- a/paste/paste.rs +++ b/paste/paste.rs @@ -23,8 +23,9 @@ mod util; static NAME: &'static str = "paste"; static VERSION: &'static str = "1.0.0"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ diff --git a/printenv/printenv.rs b/printenv/printenv.rs index 33ecdc8f4..a167c15e8 100644 --- a/printenv/printenv.rs +++ b/printenv/printenv.rs @@ -24,8 +24,9 @@ mod util; static NAME: &'static str = "printenv"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"), diff --git a/pwd/pwd.rs b/pwd/pwd.rs index 2b007b422..2df6b4c2f 100644 --- a/pwd/pwd.rs +++ b/pwd/pwd.rs @@ -23,8 +23,9 @@ mod util; static NAME: &'static str = "pwd"; static VERSION: &'static str = "1.0.0"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ getopts::optflag("", "help", "display this help and exit"), diff --git a/rm/rm.rs b/rm/rm.rs index 73d072afc..9da2a5ea1 100644 --- a/rm/rm.rs +++ b/rm/rm.rs @@ -29,8 +29,9 @@ enum InteractiveMode { static NAME: &'static str = "rm"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); // TODO: make getopts support -R in addition to -r diff --git a/rmdir/rmdir.rs b/rmdir/rmdir.rs index 136638bf5..fd71a84b2 100644 --- a/rmdir/rmdir.rs +++ b/rmdir/rmdir.rs @@ -22,8 +22,9 @@ mod util; static NAME: &'static str = "rmdir"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ diff --git a/seq/seq.rs b/seq/seq.rs index b44740642..370210489 100644 --- a/seq/seq.rs +++ b/seq/seq.rs @@ -33,8 +33,9 @@ fn escape_sequences(s: &str) -> String { replace("\\t", "\t") } -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let opts = ~[ getopts::optopt("s", "separator", "Separator character (defaults to \\n)", ""), getopts::optopt("t", "terminator", "Terminator character (defaults to separator)", ""), diff --git a/sleep/sleep.rs b/sleep/sleep.rs index bddae9858..7380e2597 100644 --- a/sleep/sleep.rs +++ b/sleep/sleep.rs @@ -23,8 +23,9 @@ mod util; static NAME: &'static str = "sleep"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ diff --git a/sum/sum.rs b/sum/sum.rs index 830dec78e..cb7fbbe1f 100644 --- a/sum/sum.rs +++ b/sum/sum.rs @@ -76,8 +76,9 @@ fn open(name: &str) -> IoResult> { } } -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).as_slice(); let opts = [ getopts::optflag("r", "", "use the BSD compatible algorithm (default)"), diff --git a/tac/tac.rs b/tac/tac.rs index 0256d1e54..adab8f74f 100644 --- a/tac/tac.rs +++ b/tac/tac.rs @@ -23,8 +23,9 @@ mod util; static NAME: &'static str = "tac"; static VERSION: &'static str = "1.0.0"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ diff --git a/tee/tee.rs b/tee/tee.rs index c3358706a..345cb040d 100644 --- a/tee/tee.rs +++ b/tee/tee.rs @@ -24,8 +24,10 @@ use getopts::{getopts, optflag, usage}; static NAME: &'static str = "tee"; static VERSION: &'static str = "1.0.0"; -fn main() { - match options(args().as_slice()).and_then(exec) { +fn main() { uumain(args()); } + +pub fn uumain(args: Vec) { + match options(args.as_slice()).and_then(exec) { Ok(_) => set_exit_status(0), Err(_) => set_exit_status(1) } diff --git a/touch/touch.rs b/touch/touch.rs index 9c69f6665..25ff0dd48 100644 --- a/touch/touch.rs +++ b/touch/touch.rs @@ -22,8 +22,9 @@ mod util; static NAME: &'static str = "touch"; static VERSION: &'static str = "1.0.0"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let opts = ~[ getopts::optflag("a", "", "change only the access time"), getopts::optflag("c", "no-create", "do not create any files"), diff --git a/tr/tr.rs b/tr/tr.rs index 0212bccf0..f99af6309 100644 --- a/tr/tr.rs +++ b/tr/tr.rs @@ -146,8 +146,8 @@ fn usage(opts: &[OptGroup]) { print(getopts::usage("Translate or delete characters.", opts).as_slice()); } -pub fn main() { - let args = os::args(); +pub fn main() { uumain(os::args()); } +pub fn uumain(args: Vec) { let opts = [ getopts::optflag("c", "complement", "use the complement of SET1"), getopts::optflag("C", "", "same as -c"), diff --git a/truncate/truncate.rs b/truncate/truncate.rs index 30feac64f..ccce94021 100644 --- a/truncate/truncate.rs +++ b/truncate/truncate.rs @@ -46,8 +46,9 @@ enum TruncateMode { static NAME: &'static str = "truncate"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ diff --git a/tty/tty.rs b/tty/tty.rs index dccb5ba98..2a8143756 100644 --- a/tty/tty.rs +++ b/tty/tty.rs @@ -34,9 +34,9 @@ extern { static NAME: &'static str = "tty"; -fn main () { - let args = os::args(); +fn main () { uumain(os::args()); } +pub fn uumain(args: Vec) { let options = [ optflag("s", "silent", "print nothing, only return an exit status") ]; diff --git a/uname/uname.rs b/uname/uname.rs index a438d1a32..e6cc63316 100644 --- a/uname/uname.rs +++ b/uname/uname.rs @@ -51,8 +51,9 @@ unsafe fn getuname() -> utsrust { static NAME: &'static str = "uname"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).as_slice(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"), diff --git a/unlink/unlink.rs b/unlink/unlink.rs index aa53a0efb..f4c17b195 100644 --- a/unlink/unlink.rs +++ b/unlink/unlink.rs @@ -26,8 +26,9 @@ mod util; static NAME: &'static str = "unlink"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"), diff --git a/uptime/uptime.rs b/uptime/uptime.rs index 9b1b4e7f5..2dab891cc 100644 --- a/uptime/uptime.rs +++ b/uptime/uptime.rs @@ -47,8 +47,9 @@ extern { fn utmpxname(file: *c_char) -> c_int; } -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ getopts::optflag("v", "version", "output version information and exit"), diff --git a/users/users.rs b/users/users.rs index 8050106e0..52d705a9b 100644 --- a/users/users.rs +++ b/users/users.rs @@ -47,8 +47,9 @@ extern { static NAME: &'static str = "users"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).as_slice(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"), diff --git a/uutils/uutils.rs b/uutils/uutils.rs new file mode 100644 index 000000000..6a91e6f40 --- /dev/null +++ b/uutils/uutils.rs @@ -0,0 +1,151 @@ +#![crate_id(name="uutils", vers="1.0.0", author="Michael Gehring")] + +/* + * This file is part of the uutils coreutils package. + * + * (c) Michael Gehring + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +extern crate collections; +extern crate getopts; + +extern crate base64; +extern crate basename; +extern crate cat; +extern crate cksum; +extern crate comm; +extern crate cp; +extern crate dirname; +extern crate du; +extern crate echo; +extern crate env; +extern crate fold; +extern crate groups; +extern crate head; +extern crate hostid; +extern crate hostname; +extern crate id; +extern crate kill; +extern crate logname; +extern crate mkdir; +extern crate paste; +extern crate printenv; +extern crate pwd; +extern crate rm; +extern crate rmdir; +extern crate seq; +extern crate sleep; +extern crate sum; +extern crate tac; +extern crate tee; +extern crate touch; +extern crate tr; +extern crate truncate; +extern crate tty; +extern crate uname; +extern crate unlink; +extern crate uptime; +extern crate users; +extern crate wc; +extern crate whoami; +extern crate yes; + +use std::os; +use collections::hashmap::HashMap; + +static NAME: &'static str = "uutils"; +static VERSION: &'static str = "1.0.0"; + +fn util_map() -> HashMap<&str, fn(Vec)> { + fn uutrue(_: Vec) { os::set_exit_status(0); } + fn uufalse(_: Vec) { os::set_exit_status(1); } + + let mut map = HashMap::new(); + map.insert("base64", base64::uumain); + map.insert("basename", basename::uumain); + map.insert("cat", cat::uumain); + map.insert("cksum", cksum::uumain); + map.insert("comm", comm::uumain); + map.insert("cp", cp::uumain); + map.insert("dirname", dirname::uumain); + map.insert("du", du::uumain); + map.insert("echo", echo::uumain); + map.insert("env", env::uumain); + map.insert("false", uufalse); + map.insert("fold", fold::uumain); + map.insert("groups", groups::uumain); + map.insert("head", head::uumain); + map.insert("hostid", hostid::uumain); + map.insert("hostname", hostname::uumain); + map.insert("id", id::uumain); + map.insert("kill", kill::uumain); + map.insert("logname", logname::uumain); + map.insert("mkdir", mkdir::uumain); + map.insert("paste", paste::uumain); + map.insert("printenv", printenv::uumain); + map.insert("pwd", pwd::uumain); + map.insert("rm", rm::uumain); + map.insert("rmdir", rmdir::uumain); + map.insert("seq", seq::uumain); + map.insert("sleep", sleep::uumain); + map.insert("sum", sum::uumain); + map.insert("tac", tac::uumain); + map.insert("tee", tee::uumain); + map.insert("touch", touch::uumain); + map.insert("tr", tr::uumain); + map.insert("true", uutrue); + map.insert("truncate", truncate::uumain); + map.insert("tty", tty::uumain); + map.insert("uname", uname::uumain); + map.insert("unlink", unlink::uumain); + map.insert("uptime", uptime::uumain); + map.insert("users", users::uumain); + map.insert("wc", wc::uumain); + map.insert("whoami", whoami::uumain); + map.insert("yes", yes::uumain); + map +} + +fn usage(cmap: &HashMap<&str, fn(Vec)>) { + println!("{} {}", NAME, VERSION); + println!(""); + println!("Usage:"); + println!(" {} [util [arguments...]", NAME); + println!("Utils:"); + let mut utils: Vec<&str> = cmap.keys().map(|&s| s).collect(); + utils.sort(); + for util in utils.iter() { + println!("\t{}", util); + } +} + +fn main() { + let umap = util_map(); + let mut args = os::args(); + + // try binary name as util name. + let binary = Path::new(args.get(0).as_slice()); + let util = binary.filename_str().unwrap(); + if umap.contains_key(&util) { + let &uumain = umap.get(&util); + uumain(args); + return + } + + // try first arg as util name. + if args.len() >= 2 { + args.shift(); + let util = args.get(0).as_slice().clone(); + if umap.contains_key(&util) { + let &uumain = umap.get(&util); + uumain(args.clone()); + return + } + } + + usage(&umap); + os::set_exit_status(1); +} diff --git a/wc/wc.rs b/wc/wc.rs index 1db8730ec..7ae4fd197 100644 --- a/wc/wc.rs +++ b/wc/wc.rs @@ -33,8 +33,9 @@ struct Result { static NAME: &'static str = "wc"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ getopts::optflag("c", "bytes", "print the byte counts"), diff --git a/whoami/whoami.rs b/whoami/whoami.rs index 75fd62107..21e870034 100644 --- a/whoami/whoami.rs +++ b/whoami/whoami.rs @@ -41,8 +41,9 @@ unsafe fn getusername() -> String { static NAME: &'static str = "whoami"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).as_slice(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"), diff --git a/yes/yes.rs b/yes/yes.rs index f846d9892..745390ae3 100644 --- a/yes/yes.rs +++ b/yes/yes.rs @@ -24,8 +24,9 @@ mod util; static NAME: &'static str = "yes"; -fn main() { - let args = os::args(); +fn main() { uumain(os::args()); } + +pub fn uumain(args: Vec) { let program = args.get(0).clone(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"),