mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
basename: use fail instead of writeln to stderr
This commit is contained in:
parent
5581cd079b
commit
7ac3e0fb2c
1 changed files with 3 additions and 10 deletions
|
@ -11,7 +11,7 @@
|
|||
|
||||
extern mod extra;
|
||||
|
||||
use std::io::{print, println, stderr};
|
||||
use std::io::{print, println};
|
||||
use std::os;
|
||||
use std::str;
|
||||
use std::str::StrSlice;
|
||||
|
@ -27,7 +27,6 @@ fn main() {
|
|||
//
|
||||
// Argument parsing
|
||||
//
|
||||
|
||||
let opts = ~[
|
||||
groups::optflag("h", "help", "display this help and exit"),
|
||||
groups::optflag("V", "version", "output version information and exit"),
|
||||
|
@ -35,12 +34,7 @@ fn main() {
|
|||
|
||||
let matches = match groups::getopts(args.tail(), opts) {
|
||||
Ok(m) => m,
|
||||
Err(f) => {
|
||||
writeln!(&mut stderr() as &mut Writer,
|
||||
"Invalid options\n{}", f.to_err_msg());
|
||||
os::set_exit_status(1);
|
||||
return;
|
||||
}
|
||||
Err(f) => fail!("Invalid options\n{}", f.to_err_msg())
|
||||
};
|
||||
|
||||
if matches.opt_present("help") {
|
||||
|
@ -95,7 +89,6 @@ fn strip_dir(fullname :&~str) -> ~str {
|
|||
if c == '/' || c == '\\' {
|
||||
return name;
|
||||
}
|
||||
|
||||
name = str::from_char(c) + name;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue