Skip to content

Commit

Permalink
Merge pull request uutils#5745 from cakebaker/cp_adapt_warning
Browse files Browse the repository at this point in the history
cp: adapt warning if source is used more than once
  • Loading branch information
sylvestre authored Dec 29, 2023
2 parents f8f8277 + 7025619 commit 448e4c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult
for source in sources {
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)
show_warning!("source {} specified more than once", source.quote());
show_warning!("source file {} specified more than once", source.quote());
} else {
let dest = construct_dest_path(source, target, target_type, options)
.unwrap_or_else(|_| target.to_path_buf());
Expand Down
4 changes: 3 additions & 1 deletion tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ fn test_cp_duplicate_files() {
.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_COPY_TO_FOLDER)
.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");
}

Expand Down

0 comments on commit 448e4c2

Please sign in to comment.