diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index ceff36b59fe..2928171b4c5 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -131,8 +131,7 @@ pub fn uu_app() -> Command { .long(options::REFERENCE) .help(translate!("chown-help-reference")) .value_name("RFILE") - .value_hint(clap::ValueHint::FilePath) - .num_args(1..), + .value_hint(clap::ValueHint::FilePath), ) .arg( Arg::new(options::verbosity::SILENT) diff --git a/tests/by-util/test_chown.rs b/tests/by-util/test_chown.rs index 33bc4b850de..4475ffdca15 100644 --- a/tests/by-util/test_chown.rs +++ b/tests/by-util/test_chown.rs @@ -6,9 +6,9 @@ #[cfg(any(target_os = "linux", target_os = "android"))] use uucore::process::geteuid; -use uutests::new_ucmd; use uutests::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root}; use uutests::util_name; +use uutests::{at_and_ucmd, new_ucmd}; // Apparently some CI environments have configuration issues, e.g. with 'whoami' and 'id'. // If we are running inside the CI and "needle" is in "stderr" skipping this test is // considered okay. If we are not inside the CI this calls assert!(result.success). @@ -844,3 +844,17 @@ fn test_chown_no_change_to_user_group() { )); } } + +#[test] +fn test_chown_reference_file() { + let (at, mut ucmd) = at_and_ucmd!(); + at.touch("a"); + at.touch("b"); + ucmd.arg("--verbose") + .arg("--reference") + .arg("a") + .arg("b") + .succeeds() + .stderr_contains("ownership of 'b' retained as") + .no_stdout(); +}