1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

update code for Rust print syntax changes

This commit is contained in:
Heather 2014-01-13 13:05:02 +04:00
parent c71a4669fa
commit ee56d7b196
14 changed files with 90 additions and 88 deletions

View file

@ -11,7 +11,7 @@
extern mod extra;
use std::io::stderr;
use std::io::{print, println, stderr};
use std::os;
use std::str;
use std::str::StrSlice;
@ -46,8 +46,8 @@ fn main() {
if matches.opt_present("help") {
println!("Usage: {0:s} NAME [SUFFIX]", program);
println!(" or: {0:s} OPTION", program);
println("Print NAME with any leading directory components removed.");
println("If specified, also remove a trailing SUFFIX.");
println!("Print NAME with any leading directory components removed.");
println!("If specified, also remove a trailing SUFFIX.");
print(groups::usage("", opts));

View file

@ -15,7 +15,7 @@
extern mod extra;
use std::os;
use std::io::{stdin, stderr, stdout, File, result};
use std::io::{print, stdin, stderr, stdout, File, result};
use extra::getopts::groups;
fn main() {
@ -44,18 +44,18 @@ fn main() {
}
};
if matches.opt_present("help") {
println("cat 1.0.0");
println("");
println("Usage:");
println!("cat 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println("");
println!("");
print(groups::usage("Concatenate FILE(s), or standard input, to standard output.", opts));
println("");
println("With no FILE, or when FILE is -, read standard input.");
println!("");
println!("With no FILE, or when FILE is -, read standard input.");
return;
}
if matches.opt_present("version") {
println("cat 1.0.0");
println!("cat 1.0.0");
return;
}

View file

@ -12,7 +12,7 @@
extern mod extra;
use std::os;
use std::io::stderr;
use std::io::{print, stderr};
use extra::getopts::groups;
static VERSION: &'static str = "1.0.0";
@ -37,11 +37,11 @@ fn main() {
};
if matches.opt_present("help") {
println("dirname " + VERSION + " - strip last component from file name");
println("");
println("Usage:");
println!("dirname {:s} - strip last component from file name", VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [OPTION] NAME...", program);
println("");
println!("");
print(groups::usage("Output each NAME with its last non-slash component and trailing slashes
removed; if NAME contains no /'s, output '.' (meaning the current
directory).", opts));
@ -49,7 +49,7 @@ directory).", opts));
}
if matches.opt_present("version") {
return println("dirname version: " + VERSION);
return println!("dirname version: {:s}", VERSION);
}
let separator = match matches.opt_present("zero") {

View file

@ -12,7 +12,7 @@
extern mod extra;
use std::os;
use std::io::stderr;
use std::io::{print, println, stderr};
use std::uint;
use extra::getopts::groups;
@ -86,12 +86,12 @@ fn main() {
};
if matches.opt_present("help") {
println("echo " + VERSION + " - display a line of text");
println("");
println("Usage:");
println!("echo {:s} - display a line of text", VERSION);
println!("");
println!("Usage:");
println!(" {0:s} [SHORT-OPTION]... [STRING]...", program);
println!(" {0:s} LONG-OPTION", program);
println("");
println!("");
println(groups::usage("Echo the STRING(s) to standard output.", opts));
println("If -e is in effect, the following sequences are recognized:
@ -111,7 +111,7 @@ fn main() {
}
if matches.opt_present("version") {
return println("echo version: " + VERSION);
return println!("echo version: {:s}", VERSION);
}
if !matches.free.is_empty() {
@ -181,6 +181,6 @@ fn main() {
}
if !matches.opt_present("n") {
println("")
println!("")
}
}

View file

@ -14,7 +14,7 @@
extern mod extra;
use std::os;
use std::io::stderr;
use std::io::{print, stderr};
use extra::getopts::groups;
fn main() {
@ -35,16 +35,16 @@ fn main() {
}
};
if matches.opt_present("help") {
println("printenv 1.0.0");
println("");
println("Usage:");
println!("printenv 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [VARIABLE]... [OPTION]...", program);
println("");
println!("");
print(groups::usage("Prints the given environment VARIABLE(s), otherwise prints them all.", opts));
return;
}
if matches.opt_present("version") {
println("printenv 1.0.0");
println!("printenv 1.0.0");
return;
}
let mut separator = "\n";

View file

@ -12,7 +12,7 @@
extern mod extra;
use std::os;
use std::io::stderr;
use std::io::{print, stderr};
use extra::getopts::groups;
static VERSION: &'static str = "1.0.0";
@ -37,13 +37,13 @@ fn main() {
if matches.opt_present("help") {
println!("pwd {}", VERSION);
println("");
println("Usage:");
println!("");
println!("Usage:");
println!(" {0:s} [OPTION] NAME...", program);
println("");
println!("");
print(groups::usage("Print the full filename of the current working directory.", opts));
} else if matches.opt_present("version") {
return println("pwd version: " + VERSION);
return println!("pwd version: {}", VERSION);
} else {
let cwd = std::os::getcwd();
println!("{}", cwd.display());

View file

@ -12,7 +12,7 @@
extern mod extra;
use std::os;
use std::io::{stdin,stderr,stdio,fs,buffered,io_error};
use std::io::{print,stdin,stderr,stdio,fs,buffered,io_error};
use extra::getopts::groups;
enum InteractiveMode {
@ -65,27 +65,27 @@ fn main() {
}
};
if matches.opt_present("help") {
println("rm 1.0.0");
println("");
println("Usage:");
println!("rm 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println("");
println!("");
print(groups::usage("Remove (unlink) the FILE(s).", opts));
println("");
println("By default, rm does not remove directories. Use the --recursive (-r)");
println("option to remove each listed directory, too, along with all of its contents");
println("");
println("To remove a file whose name starts with a '-', for example '-foo',");
println("use one of these commands:");
println("rm -- -foo");
println("");
println("rm ./-foo");
println("");
println("Note that if you use rm to remove a file, it might be possible to recover");
println("some of its contents, given sufficient expertise and/or time. For greater");
println("assurance that the contents are truly unrecoverable, consider using shred.");
println!("");
println!("By default, rm does not remove directories. Use the --recursive (-r)");
println!("option to remove each listed directory, too, along with all of its contents");
println!("");
println!("To remove a file whose name starts with a '-', for example '-foo',");
println!("use one of these commands:");
println!("rm -- -foo");
println!("");
println!("rm ./-foo");
println!("");
println!("Note that if you use rm to remove a file, it might be possible to recover");
println!("some of its contents, given sufficient expertise and/or time. For greater");
println!("assurance that the contents are truly unrecoverable, consider using shred.");
} else if matches.opt_present("version") {
println("rm 1.0.0");
println!("rm 1.0.0");
} else if matches.free.is_empty() {
writeln!(&mut stderr() as &mut Writer, "Missing an argument");
writeln!(&mut stderr() as &mut Writer,
@ -231,7 +231,7 @@ fn read_prompt() -> bool {
'y' | 'Y' => true,
'n' | 'N' => false,
_ => {
print("Please enter either Y or N: ");
print!("Please enter either Y or N: ");
read_prompt()
}
}

View file

@ -12,7 +12,7 @@
extern mod extra;
use std::os;
use std::io::{stderr, io_error, fs};
use std::io::{print, stderr, io_error, fs};
use extra::getopts::groups;
fn main() {
@ -36,14 +36,14 @@ fn main() {
};
if matches.opt_present("help") {
println("rmdir 1.0.0");
println("");
println("Usage:");
println!("rmdir 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [OPTION]... DIRECTORY...", program);
println("");
println!("");
print(groups::usage("Remove the DIRECTORY(ies), if they are empty.", opts));
} else if matches.opt_present("version") {
println("rmdir 1.0.0");
println!("rmdir 1.0.0");
} else if matches.free.is_empty() {
writeln!(&mut stderr() as &mut Writer, "Missing an argument");
writeln!(&mut stderr() as &mut Writer,

View file

@ -14,7 +14,7 @@ extern mod extra;
use std::num;
use std::cast;
use std::os;
use std::io::{stderr, timer};
use std::io::{print, stderr, timer};
use extra::getopts::groups;
fn main() {
@ -35,20 +35,20 @@ fn main() {
};
if matches.opt_present("help") {
println("sleep 1.0.0");
println("");
println("Usage:");
println!("sleep 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} NUMBER[SUFFIX]", program);
println("or");
println!("or");
println!(" {0:s} OPTION", program);
println("");
println!("");
print(groups::usage("Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default),
'm' for minutes, 'h' for hours or 'd' for days. Unlike most implementations
that require NUMBER be an integer, here NUMBER may be an arbitrary floating
point number. Given two or more arguments, pause for the amount of time
specified by the sum of their values.", opts));
} else if matches.opt_present("version") {
println("sleep 1.0.0");
println!("sleep 1.0.0");
} else if matches.free.is_empty() {
writeln!(&mut stderr() as &mut Writer, "Missing an argument");
writeln!(&mut stderr() as &mut Writer,

View file

@ -12,7 +12,7 @@
extern mod extra;
use std::io::{stdin, stdout, Append, File, Truncate, Write};
use std::io::{println, stdin, stdout, Append, File, Truncate, Write};
use std::io::{io_error, EndOfFile};
use std::io::signal::{Interrupt, Listener};
use std::io::util::{copy, NullWriter, MultiWriter};

View file

@ -15,6 +15,7 @@
extern mod extra;
use std::{libc,str,os};
use std::io::println;
use std::io::stdio::stderr;
use extra::getopts::{optflag,getopts};
@ -47,7 +48,7 @@ fn main () {
if !tty.is_whitespace() {
println(tty);
} else {
println("not a tty");
println!("not a tty");
}
}

View file

@ -12,7 +12,7 @@
extern mod extra;
use std::os;
use std::io::{stdin, stderr, File, result};
use std::io::{print, stdin, stderr, File, result};
use std::io::buffered::BufferedReader;
use std::str::from_utf8_opt;
use extra::getopts::{groups, Matches};
@ -50,17 +50,17 @@ fn main() {
};
if matches.opt_present("help") {
println("Usage:");
println!("Usage:");
println!(" {0:s} [OPTION]... [FILE]...", program);
println("");
println!("");
print(groups::usage("Print newline, word and byte counts for each FILE", opts));
println("");
println("With no FILE, or when FILE is -, read standard input.");
println!("");
println!("With no FILE, or when FILE is -, read standard input.");
return;
}
if (matches.opt_present("version")) {
println("wc 1.0.0");
println!("wc 1.0.0");
return;
}
@ -211,7 +211,7 @@ fn print_stats(filename: &~str, line_count: uint, word_count: uint, char_count:
println!(" {}", *filename);
}
else {
println("");
println!("");
}
}

View file

@ -13,6 +13,7 @@
extern mod extra;
use std::io::print;
use std::os;
use std::str;
use std::libc;
@ -49,16 +50,16 @@ fn main() {
Err(f) => fail!(f.to_err_msg()),
};
if matches.opt_present("help") {
println("whoami 1.0.0");
println("");
println("Usage:");
println!("whoami 1.0.0");
println!("");
println!("Usage:");
println!(" {:s}", program);
println("");
println!("");
print(groups::usage("print effective userid", opts));
return;
}
if matches.opt_present("version") {
println("whoami 1.0.0");
println!("whoami 1.0.0");
return;
}

View file

@ -14,7 +14,7 @@
extern mod extra;
use std::os;
use std::io::stderr;
use std::io::{print, println, stderr};
use extra::getopts::groups;
fn main() {
@ -34,16 +34,16 @@ fn main() {
}
};
if matches.opt_present("help") {
println("yes 1.0.0");
println("");
println("Usage:");
println!("yes 1.0.0");
println!("");
println!("Usage:");
println!(" {0:s} [STRING]... [OPTION]...", program);
println("");
println!("");
print(groups::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", opts));
return;
}
if matches.opt_present("version") {
println("yes 1.0.0");
println!("yes 1.0.0");
return;
}
let mut string = ~"y";