mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
[truncate] change cli error return code
Exit with status code 1 for argument parsing errors in `truncate`. When `clap` encounters an error during argument parsing, it exits with status code 2. This causes some GNU tests to fail since they expect status code 1.
This commit is contained in:
parent
7b3cfcf708
commit
cd1b5c5748
1 changed files with 11 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
||||||
// * file that was distributed with this source code.
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize
|
// spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize
|
||||||
|
use clap;
|
||||||
use clap::{crate_version, App, AppSettings, Arg};
|
use clap::{crate_version, App, AppSettings, Arg};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fs::{metadata, OpenOptions};
|
use std::fs::{metadata, OpenOptions};
|
||||||
|
@ -115,7 +116,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let matches = uu_app()
|
let matches = uu_app()
|
||||||
.override_usage(&usage[..])
|
.override_usage(&usage[..])
|
||||||
.after_help(&long_usage[..])
|
.after_help(&long_usage[..])
|
||||||
.get_matches_from(args);
|
.try_get_matches_from(args)
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
|
e.print();
|
||||||
|
match e.kind {
|
||||||
|
clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => {
|
||||||
|
std::process::exit(0)
|
||||||
|
}
|
||||||
|
_ => std::process::exit(1),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let files: Vec<String> = matches
|
let files: Vec<String> = matches
|
||||||
.values_of(options::ARG_FILES)
|
.values_of(options::ARG_FILES)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue