mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #4928 from granquet/cp_preserve
cp: makes --preserve requires =
This commit is contained in:
commit
99fa504257
2 changed files with 28 additions and 0 deletions
|
@ -515,6 +515,7 @@ pub fn uu_app() -> Command {
|
||||||
PRESERVABLE_ATTRIBUTES,
|
PRESERVABLE_ATTRIBUTES,
|
||||||
))
|
))
|
||||||
.num_args(0..)
|
.num_args(0..)
|
||||||
|
.require_equals(true)
|
||||||
.value_name("ATTR_LIST")
|
.value_name("ATTR_LIST")
|
||||||
.overrides_with_all([
|
.overrides_with_all([
|
||||||
options::ARCHIVE,
|
options::ARCHIVE,
|
||||||
|
|
|
@ -1223,6 +1223,33 @@ fn test_cp_preserve_no_args() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cp_preserve_no_args_before_opts() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
let src_file = "a";
|
||||||
|
let dst_file = "b";
|
||||||
|
|
||||||
|
// Prepare the source file
|
||||||
|
at.touch(src_file);
|
||||||
|
#[cfg(unix)]
|
||||||
|
at.set_mode(src_file, 0o0500);
|
||||||
|
|
||||||
|
// Copy
|
||||||
|
ucmd.arg("--preserve")
|
||||||
|
.arg(src_file)
|
||||||
|
.arg(dst_file)
|
||||||
|
.succeeds();
|
||||||
|
|
||||||
|
#[cfg(all(unix, not(target_os = "freebsd")))]
|
||||||
|
{
|
||||||
|
// Assert that the mode, ownership, and timestamps are preserved
|
||||||
|
// NOTICE: the ownership is not modified on the src file, because that requires root permissions
|
||||||
|
let metadata_src = at.metadata(src_file);
|
||||||
|
let metadata_dst = at.metadata(dst_file);
|
||||||
|
assert_metadata_eq!(metadata_src, metadata_dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cp_preserve_all() {
|
fn test_cp_preserve_all() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue