@@ -29,7 +29,7 @@ use platform::copy_on_write;
2929use uucore:: display:: Quotable ;
3030use uucore:: error:: { set_exit_code, UClapError , UError , UResult , UUsageError } ;
3131use uucore:: fs:: {
32- are_hardlinks_to_same_file, canonicalize, get_filename, is_symlink_loop,
32+ are_hardlinks_to_same_file, canonicalize, get_filename, is_symlink_loop, normalize_path ,
3333 path_ends_with_terminator, paths_refer_to_same_file, FileInformation , MissingHandling ,
3434 ResolveMode ,
3535} ;
@@ -1264,8 +1264,8 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult
12641264 } ;
12651265
12661266 for source in sources {
1267- if seen_sources . contains ( source) {
1268- // FIXME: compare sources by the actual file they point to, not their path. (e.g. dir/file == dir/../dir/file in most cases)
1267+ let normalized_source = normalize_path ( source) ;
1268+ if seen_sources . contains ( & normalized_source ) {
12691269 show_warning ! ( "source file {} specified more than once" , source. quote( ) ) ;
12701270 } else {
12711271 let dest = construct_dest_path ( source, target, target_type, options)
@@ -1309,7 +1309,7 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult
13091309 copied_destinations. insert ( dest. clone ( ) ) ;
13101310 }
13111311 }
1312- seen_sources. insert ( source ) ;
1312+ seen_sources. insert ( normalized_source ) ;
13131313 }
13141314
13151315 if let Some ( pb) = progress_bar {
0 commit comments