mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cp: adapt warning if source is used more than once
This commit is contained in:
parent
91080b152f
commit
7025619325
2 changed files with 4 additions and 2 deletions
|
@ -1193,7 +1193,7 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult
|
||||||
for source in sources {
|
for source in sources {
|
||||||
if seen_sources.contains(source) {
|
if seen_sources.contains(source) {
|
||||||
// FIXME: compare sources by the actual file they point to, not their path. (e.g. dir/file == dir/../dir/file in most cases)
|
// FIXME: compare sources by the actual file they point to, not their path. (e.g. dir/file == dir/../dir/file in most cases)
|
||||||
show_warning!("source {} specified more than once", source.quote());
|
show_warning!("source file {} specified more than once", source.quote());
|
||||||
} else {
|
} else {
|
||||||
let dest = construct_dest_path(source, target, target_type, options)
|
let dest = construct_dest_path(source, target, target_type, options)
|
||||||
.unwrap_or_else(|_| target.to_path_buf());
|
.unwrap_or_else(|_| target.to_path_buf());
|
||||||
|
|
|
@ -111,7 +111,9 @@ fn test_cp_duplicate_files() {
|
||||||
.arg(TEST_HELLO_WORLD_SOURCE)
|
.arg(TEST_HELLO_WORLD_SOURCE)
|
||||||
.arg(TEST_COPY_TO_FOLDER)
|
.arg(TEST_COPY_TO_FOLDER)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stderr_contains("specified more than once");
|
.stderr_contains(format!(
|
||||||
|
"source file '{TEST_HELLO_WORLD_SOURCE}' specified more than once"
|
||||||
|
));
|
||||||
assert_eq!(at.read(TEST_COPY_TO_FOLDER_FILE), "Hello, World!\n");
|
assert_eq!(at.read(TEST_COPY_TO_FOLDER_FILE), "Hello, World!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue