id: mark passwd-format and pretty-print as conflicting

These are non-sensical to combine, and didn't work reasonably anyway.
Also, passwd-formatting is our own extension, so there is no need for
compatibility anyway.
This commit is contained in:
Ben Wiederhake 2024-04-28 23:05:43 +02:00
parent e978fe5382
commit 4f5a3b4716
2 changed files with 14 additions and 0 deletions

View file

@ -397,6 +397,7 @@ pub fn uu_app() -> Command {
Arg::new(options::OPT_PASSWORD)
.short('P')
.help("Display the id as a password file entry.")
.conflicts_with(options::OPT_HUMAN_READABLE)
.action(ArgAction::SetTrue),
)
.arg(

View file

@ -461,3 +461,16 @@ fn test_id_no_specified_user_posixly() {
}
}
}
#[test]
#[cfg(all(unix, not(target_os = "android")))]
fn test_id_pretty_print_password_record() {
// `-p` is BSD only and not supported on GNU's `id`.
// `-P` is our own extension, and not supported by either GNU nor BSD.
// These must conflict, because they both set the output format.
new_ucmd!()
.arg("-p")
.arg("-P")
.fails()
.stderr_contains("the argument '-p' cannot be used with '-P'");
}