Skip to content

Commit 2c9a27c

Browse files
Merge pull request #8492 from Anonymous-AAA/fix-chown-reference-file
chown: fix --reference file syntax
1 parent 21de2c8 commit 2c9a27c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/uu/chown/src/chown.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ pub fn uu_app() -> Command {
131131
.long(options::REFERENCE)
132132
.help(translate!("chown-help-reference"))
133133
.value_name("RFILE")
134-
.value_hint(clap::ValueHint::FilePath)
135-
.num_args(1..),
134+
.value_hint(clap::ValueHint::FilePath),
136135
)
137136
.arg(
138137
Arg::new(options::verbosity::SILENT)

tests/by-util/test_chown.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
#[cfg(any(target_os = "linux", target_os = "android"))]
88
use uucore::process::geteuid;
9-
use uutests::new_ucmd;
109
use uutests::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root};
1110
use uutests::util_name;
11+
use uutests::{at_and_ucmd, new_ucmd};
1212
// Apparently some CI environments have configuration issues, e.g. with 'whoami' and 'id'.
1313
// If we are running inside the CI and "needle" is in "stderr" skipping this test is
1414
// 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() {
844844
));
845845
}
846846
}
847+
848+
#[test]
849+
fn test_chown_reference_file() {
850+
let (at, mut ucmd) = at_and_ucmd!();
851+
at.touch("a");
852+
at.touch("b");
853+
ucmd.arg("--verbose")
854+
.arg("--reference")
855+
.arg("a")
856+
.arg("b")
857+
.succeeds()
858+
.stderr_contains("ownership of 'b' retained as")
859+
.no_stdout();
860+
}

0 commit comments

Comments
 (0)