pr: return correct exit code on error

This commit is contained in:
Ben Wiederhake 2024-03-31 21:19:24 +02:00
parent f5f8cf08e0
commit 9527341714
2 changed files with 10 additions and 7 deletions

View file

@ -386,13 +386,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let opt_args = recreate_arguments(&args);
let mut command = uu_app();
let matches = match command.try_get_matches_from_mut(opt_args) {
Ok(m) => m,
Err(e) => {
e.print()?;
return Ok(());
}
};
let matches = command.try_get_matches_from_mut(opt_args)?;
let mut files = matches
.get_many::<String>(options::FILES)

View file

@ -43,6 +43,15 @@ fn valid_last_modified_template_vars(from: DateTime<Utc>) -> Vec<Vec<(String, St
.collect()
}
#[test]
fn test_invalid_flag() {
new_ucmd!()
.arg("--invalid-argument")
.fails()
.no_stdout()
.code_is(1);
}
#[test]
fn test_without_any_options() {
let test_file_path = "test_one_page.log";