From 4b9c8279cecfca8ea950d9414c17601282e21907 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Fri, 16 May 2014 10:32:58 +0200 Subject: [PATCH] os::args returns Vec<~str> now --- base64/base64.rs | 2 +- basename/basename.rs | 8 ++++---- cat/cat.rs | 2 +- dirname/dirname.rs | 2 +- du/du.rs | 2 +- echo/echo.rs | 2 +- fold/fold.rs | 4 ++-- hostname/hostname.rs | 2 +- logname/logname.rs | 2 +- md5sum/md5sum.rs | 2 +- paste/paste.rs | 2 +- printenv/printenv.rs | 2 +- pwd/pwd.rs | 2 +- rm/rm.rs | 2 +- rmdir/rmdir.rs | 2 +- sleep/sleep.rs | 2 +- tac/tac.rs | 2 +- tee/tee.rs | 4 ++-- truncate/truncate.rs | 2 +- uname/uname.rs | 2 +- uptime/uptime.rs | 2 +- users/users.rs | 2 +- wc/wc.rs | 2 +- whoami/whoami.rs | 2 +- yes/yes.rs | 2 +- 25 files changed, 30 insertions(+), 30 deletions(-) diff --git a/base64/base64.rs b/base64/base64.rs index 14dc03e1a..fcec28d6c 100644 --- a/base64/base64.rs +++ b/base64/base64.rs @@ -55,7 +55,7 @@ fn main() { } }; - let progname = args[0].clone(); + let progname = args.get(0).clone(); let usage = usage("Base64 encode or decode FILE, or standard input, to standard output.", opts); let mode = if matches.opt_present("help") { Help diff --git a/basename/basename.rs b/basename/basename.rs index 99587bd1b..b82dc037d 100644 --- a/basename/basename.rs +++ b/basename/basename.rs @@ -25,7 +25,7 @@ static VERSION: &'static str = "1.0.0"; fn main() { let args = os::args(); - let program = strip_dir(&args[ 0 ].clone()); + let program = strip_dir(args.get(0)); // // Argument parsing @@ -64,7 +64,7 @@ fn main() { } // too many arguments else if args.len() > 3 { - println(program + ": extra operand `" + args[ 3 ] + "'"); + println(program + ": extra operand `" + args.get(3).clone() + "'"); println("Try `" + program + " --help' for more information."); return; } @@ -73,12 +73,12 @@ fn main() { // Main Program Processing // - let fullname = args[ 1 ].clone(); + let fullname = args.get(1).clone(); let mut name = strip_dir(&fullname); if args.len() > 2 { - let suffix = args[ 2 ].clone(); + let suffix = args.get(2).clone(); name = strip_suffix(&name, &suffix); } diff --git a/cat/cat.rs b/cat/cat.rs index 81260e774..758929fb9 100644 --- a/cat/cat.rs +++ b/cat/cat.rs @@ -21,7 +21,7 @@ use std::io::{BufferedWriter}; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("A", "show-all", "equivalent to -vET"), getopts::optflag("b", "number-nonblank", "number nonempty output lines, overrides -n"), diff --git a/dirname/dirname.rs b/dirname/dirname.rs index c1f6439b0..f3bbdc2b8 100644 --- a/dirname/dirname.rs +++ b/dirname/dirname.rs @@ -18,7 +18,7 @@ static VERSION: &'static str = "1.0.0"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("z", "zero", "separate output with NUL rather than newline"), getopts::optflag("", "help", "display this help and exit"), diff --git a/du/du.rs b/du/du.rs index a586b00c8..18c74f938 100644 --- a/du/du.rs +++ b/du/du.rs @@ -88,7 +88,7 @@ fn du(path: &Path, mut my_stat: FileStat, fn main() { let args = os::args(); - let program = args[0].as_slice(); + let program = args.get(0).as_slice(); let opts = ~[ // In task getopts::optflag("a", "all", " write counts for all files, not just directories"), diff --git a/echo/echo.rs b/echo/echo.rs index d91c76bc6..d93ff303a 100644 --- a/echo/echo.rs +++ b/echo/echo.rs @@ -71,7 +71,7 @@ fn convert_str(string: &str, index: uint, base: uint) -> (char, int) { fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("n", "", "do not output the trailing newline"), getopts::optflag("e", "", "enable interpretation of backslash escapes"), diff --git a/fold/fold.rs b/fold/fold.rs index cfeddb150..187f3754e 100644 --- a/fold/fold.rs +++ b/fold/fold.rs @@ -29,9 +29,9 @@ static VERSION: &'static str = "1.0.0"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); - let (args, obs_width) = handle_obsolete(args); + let (args, obs_width) = handle_obsolete(args.as_slice().to_owned()); let opts = [ getopts::optflag("b", "bytes", "count using bytes rather than columns (meaning control characters such as newline are not treated specially)"), diff --git a/hostname/hostname.rs b/hostname/hostname.rs index 27d3ef240..d5c99bb2a 100644 --- a/hostname/hostname.rs +++ b/hostname/hostname.rs @@ -25,7 +25,7 @@ extern { fn main () { let args = os::args(); - let program = args[0].to_owned(); + let program = args.get(0).to_owned(); let options = [ optflag("f", "full", "Default option to show full name"), diff --git a/logname/logname.rs b/logname/logname.rs index de489f483..243a8d790 100644 --- a/logname/logname.rs +++ b/logname/logname.rs @@ -45,7 +45,7 @@ fn version() { fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); // // Argument parsing diff --git a/md5sum/md5sum.rs b/md5sum/md5sum.rs index 687c8116f..438886750 100644 --- a/md5sum/md5sum.rs +++ b/md5sum/md5sum.rs @@ -30,7 +30,7 @@ static VERSION: &'static str = "1.0.0"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = [ getopts::optflag("b", "binary", "read in binary mode"), diff --git a/paste/paste.rs b/paste/paste.rs index 921e7df3f..164ff6133 100644 --- a/paste/paste.rs +++ b/paste/paste.rs @@ -25,7 +25,7 @@ static VERSION: &'static str = "1.0.0"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("s", "serial", "paste one file at a time instead of in parallel"), diff --git a/printenv/printenv.rs b/printenv/printenv.rs index 0c87df0f3..b5c87d73b 100644 --- a/printenv/printenv.rs +++ b/printenv/printenv.rs @@ -26,7 +26,7 @@ static NAME: &'static str = "printenv"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"), getopts::optflag("h", "help", "display this help and exit"), diff --git a/pwd/pwd.rs b/pwd/pwd.rs index 4661ebf30..4ca5cc016 100644 --- a/pwd/pwd.rs +++ b/pwd/pwd.rs @@ -25,7 +25,7 @@ static VERSION: &'static str = "1.0.0"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("", "help", "display this help and exit"), getopts::optflag("", "version", "output version information and exit"), diff --git a/rm/rm.rs b/rm/rm.rs index 3ffc19b09..3ce712abb 100644 --- a/rm/rm.rs +++ b/rm/rm.rs @@ -31,7 +31,7 @@ static NAME: &'static str = "rm"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); // TODO: make getopts support -R in addition to -r let opts = ~[ diff --git a/rmdir/rmdir.rs b/rmdir/rmdir.rs index be9efebe1..b4dfc3a36 100644 --- a/rmdir/rmdir.rs +++ b/rmdir/rmdir.rs @@ -24,7 +24,7 @@ static NAME: &'static str = "rmdir"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("", "ignore-fail-on-non-empty", "ignore each failure that is solely because a directory is non-empty"), diff --git a/sleep/sleep.rs b/sleep/sleep.rs index 01c5bed90..cdf5c7ddb 100644 --- a/sleep/sleep.rs +++ b/sleep/sleep.rs @@ -25,7 +25,7 @@ static NAME: &'static str = "sleep"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"), diff --git a/tac/tac.rs b/tac/tac.rs index cd06a678d..37187dbfe 100644 --- a/tac/tac.rs +++ b/tac/tac.rs @@ -25,7 +25,7 @@ static VERSION: &'static str = "1.0.0"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("b", "before", "attach the separator before instead of after"), diff --git a/tee/tee.rs b/tee/tee.rs index 36459aceb..a2339e72b 100644 --- a/tee/tee.rs +++ b/tee/tee.rs @@ -25,7 +25,7 @@ static NAME: &'static str = "tee"; static VERSION: &'static str = "1.0.0"; fn main() { - match options(args()).and_then(exec) { + match options(args().as_slice()).and_then(exec) { Ok(_) => set_exit_status(0), Err(_) => set_exit_status(1) } @@ -149,5 +149,5 @@ fn with_path(path: &Path, cb: || -> IoResult) -> IoResult { } fn warn(message: &str) { - error!("{}: {}", args()[0], message); + error!("{}: {}", args().get(0), message); } diff --git a/truncate/truncate.rs b/truncate/truncate.rs index 04ad57c44..74c88dbb7 100644 --- a/truncate/truncate.rs +++ b/truncate/truncate.rs @@ -48,7 +48,7 @@ static NAME: &'static str = "truncate"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("c", "no-create", "do not create files that do not exist"), diff --git a/uname/uname.rs b/uname/uname.rs index aaefedc1e..8546da39f 100644 --- a/uname/uname.rs +++ b/uname/uname.rs @@ -53,7 +53,7 @@ static NAME: &'static str = "uname"; fn main() { let args = os::args(); - let program = args[0].as_slice(); + let program = args.get(0).as_slice(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("a", "all", "Behave as though all of the options -mnrsv were specified."), diff --git a/uptime/uptime.rs b/uptime/uptime.rs index cb5e328de..bc8173ab0 100644 --- a/uptime/uptime.rs +++ b/uptime/uptime.rs @@ -49,7 +49,7 @@ extern { fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("v", "version", "output version information and exit"), getopts::optflag("h", "help", "display this help and exit"), diff --git a/users/users.rs b/users/users.rs index d9319794a..77f3da0a6 100644 --- a/users/users.rs +++ b/users/users.rs @@ -49,7 +49,7 @@ static NAME: &'static str = "users"; fn main() { let args = os::args(); - let program = args[0].as_slice(); + let program = args.get(0).as_slice(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), diff --git a/wc/wc.rs b/wc/wc.rs index fc6ee9ac1..cf77a5a82 100644 --- a/wc/wc.rs +++ b/wc/wc.rs @@ -35,7 +35,7 @@ static NAME: &'static str = "wc"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("c", "bytes", "print the byte counts"), getopts::optflag("m", "chars", "print the character counts"), diff --git a/whoami/whoami.rs b/whoami/whoami.rs index 9b7ad244e..d407a0800 100644 --- a/whoami/whoami.rs +++ b/whoami/whoami.rs @@ -43,7 +43,7 @@ static NAME: &'static str = "whoami"; fn main() { let args = os::args(); - let program = args[0].as_slice(); + let program = args.get(0).as_slice(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"), diff --git a/yes/yes.rs b/yes/yes.rs index 47bde021a..c8c2b7365 100644 --- a/yes/yes.rs +++ b/yes/yes.rs @@ -26,7 +26,7 @@ static NAME: &'static str = "yes"; fn main() { let args = os::args(); - let program = args[0].clone(); + let program = args.get(0).clone(); let opts = ~[ getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("V", "version", "output version information and exit"),