mirror of
https://github.com/uutils/coreutils
synced 2024-11-15 09:27:21 +00:00
dirname, basename, env, head, id, sync, touch: exit with status 1 on invalid arguments
This commit is contained in:
parent
fc26e0cfea
commit
bb1edec74e
7 changed files with 11 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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
4
env/env.rs
vendored
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
2
id/id.rs
2
id/id.rs
|
@ -105,7 +105,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
Ok(m) => { m },
|
||||
Err(_) => {
|
||||
println!("{:s}", usage(NAME, options));
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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") {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue