hostid: return correct exit code on error

This commit is contained in:
Ben Wiederhake 2024-03-31 21:08:01 +02:00
parent 333e4d9fe9
commit f5f8cf08e0
2 changed files with 10 additions and 1 deletions

View file

@ -19,7 +19,7 @@ extern "C" {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
uu_app().get_matches_from(args);
uu_app().try_get_matches_from(args)?;
hostid();
Ok(())
}

View file

@ -10,3 +10,12 @@ fn test_normal() {
let re = Regex::new(r"^[0-9a-f]{8}").unwrap();
new_ucmd!().succeeds().stdout_matches(&re);
}
#[test]
fn test_invalid_flag() {
new_ucmd!()
.arg("--invalid-argument")
.fails()
.no_stdout()
.code_is(1);
}