dirname, basename, env, head, id, sync, touch: exit with status 1 on invalid arguments

This commit is contained in:
Michael Gehring 2014-06-22 16:44:31 +02:00
parent fc26e0cfea
commit bb1edec74e
7 changed files with 11 additions and 7 deletions

View file

@ -62,13 +62,13 @@ pub fn uumain(args: Vec<String>) -> int {
if args.len() < 2 {
println!("{}: {}", program, "missing operand");
println!("Try '{} --help' for more information.", program);
return 0;
return 1;
}
// too many arguments
else if args.len() > 3 {
println!("{}: extra operand '{}'", program, args.get(3));
println!("Try '{} --help' for more information.", program);
return 0;
return 1;
}
//

View file

@ -66,6 +66,7 @@ directory).", opts).as_slice());
} else {
println!("{0:s}: missing operand", program);
println!("Try '{0:s} --help' for more information.", program);
return 1;
}
0

4
env/env.rs vendored
View file

@ -114,7 +114,7 @@ pub fn uumain(args: Vec<String>) -> int {
_ => {
println!("{:s}: invalid option \"{:s}\"", prog, *opt);
println!("Type \"{:s} --help\" for detailed informations", prog);
return 0;
return 1;
}
}
} else if opt.as_slice().starts_with("-") {
@ -146,7 +146,7 @@ pub fn uumain(args: Vec<String>) -> int {
_ => {
println!("{:s}: illegal option -- {:c}", prog, c);
println!("Type \"{:s} --help\" for detailed informations", prog);
return 0;
return 1;
}
}
}

View file

@ -46,7 +46,7 @@ pub fn uumain(args: Vec<String>) -> int {
Ok (m) => { m }
Err(_) => {
println!("{:s}", usage(PROGRAM, possible_options));
return 0;
return 1;
}
};

View file

@ -105,7 +105,7 @@ pub fn uumain(args: Vec<String>) -> int {
Ok(m) => { m },
Err(_) => {
println!("{:s}", usage(NAME, options));
return 0;
return 1;
}
};

View file

@ -33,7 +33,7 @@ pub fn uumain(args: Vec<String>) -> int {
let matches = match getopts(args.tail(), options) {
Ok(m) => { m }
_ => { help(program.as_slice(), options); return 0 }
_ => { help(program.as_slice(), options); return 1 }
};
if matches.opt_present("h") {

View file

@ -59,6 +59,9 @@ pub fn uumain(args: Vec<String>) -> int {
println!("");
println!("{:s}", getopts::usage("Update the access and modification times of \
each FILE to the current time.", opts));
if matches.free.is_empty() {
return 1;
}
return 0;
}