From 2a7209116d9199b03fa3aaa90e7829837591b75b Mon Sep 17 00:00:00 2001 From: Hanif Bin Ariffin Date: Sun, 13 Jun 2021 07:33:14 +0800 Subject: [PATCH 1/2] Fixed cp --preserve accepting no args Signed-off-by: Hanif Bin Ariffin --- src/uu/cp/src/cp.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index a87e86b98..2ebbeddb0 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -396,6 +396,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .multiple(true) .use_delimiter(true) .possible_values(PRESERVABLE_ATTRIBUTES) + .min_values(0) .value_name("ATTR_LIST") .conflicts_with_all(&[OPT_PRESERVE_DEFAULT_ATTRIBUTES, OPT_NO_PRESERVE]) // -d sets this option From 23de1811711455c6130b0115661e1d8533ebcd22 Mon Sep 17 00:00:00 2001 From: Hanif Bin Ariffin Date: Wed, 16 Jun 2021 11:32:15 +0800 Subject: [PATCH 2/2] Added tests for cp --preserve without args Signed-off-by: Hanif Bin Ariffin --- tests/by-util/test_cp.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index bc6c6fc79..83b199bc4 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -726,6 +726,15 @@ fn test_cp_parents_dest_not_directory() { .stderr_contains("with --parents, the destination must be a directory"); } +#[test] +fn test_cp_preserve_no_args() { + new_ucmd!() + .arg(TEST_COPY_FROM_FOLDER_FILE) + .arg(TEST_HELLO_WORLD_DEST) + .arg("--preserve") + .succeeds(); +} + #[test] // For now, disable the test on Windows. Symlinks aren't well support on Windows. // It works on Unix for now and it works locally when run from a powershell