mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +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;
|
extern mod extra;
|
||||||
|
|
||||||
use std::io::{print, println, stderr};
|
use std::io::{print, println};
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::str::StrSlice;
|
use std::str::StrSlice;
|
||||||
|
@ -27,7 +27,6 @@ fn main() {
|
||||||
//
|
//
|
||||||
// Argument parsing
|
// Argument parsing
|
||||||
//
|
//
|
||||||
|
|
||||||
let opts = ~[
|
let opts = ~[
|
||||||
groups::optflag("h", "help", "display this help and exit"),
|
groups::optflag("h", "help", "display this help and exit"),
|
||||||
groups::optflag("V", "version", "output version information 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) {
|
let matches = match groups::getopts(args.tail(), opts) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => {
|
Err(f) => fail!("Invalid options\n{}", f.to_err_msg())
|
||||||
writeln!(&mut stderr() as &mut Writer,
|
|
||||||
"Invalid options\n{}", f.to_err_msg());
|
|
||||||
os::set_exit_status(1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches.opt_present("help") {
|
if matches.opt_present("help") {
|
||||||
|
@ -95,7 +89,6 @@ fn strip_dir(fullname :&~str) -> ~str {
|
||||||
if c == '/' || c == '\\' {
|
if c == '/' || c == '\\' {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = str::from_char(c) + name;
|
name = str::from_char(c) + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue