Skip to content

Commit bddea50

Browse files
KelpHectclaude
andcommitted
skua: cp names a missing source on Windows (fix of a6a1341)
The missing source reached the copy loop as CpError::Error(String) with Windows' text, not as CpError::IoErr, so a6a1341's arm never matched (CI: test_cp_multiple_files_with_nonexistent_file / _empty_file_name). On Windows the loop now checks the source itself, as GNU cp stats it first, and prints `cp: cannot stat 'x': No such file or directory`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a86ff7a commit bddea50

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎src/uu/cp/src/cp.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,9 +1541,13 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult
15411541
&mut created_parent_dirs,
15421542
) {
15431543
match &error {
1544-
// Skua: on Windows a missing source fails before any call that adds the
1545-
// path; say what GNU cp says (`cannot stat 'x': No such file or directory`).
1546-
CpError::IoErr(io_err) if io_err.kind() == io::ErrorKind::NotFound => {
1544+
// Skua: on Windows a missing source fails in a call that drops the path
1545+
// (`cp: <Windows text> (os error 2)`); say what GNU cp says, which stats
1546+
// the source first: `cannot stat 'x': No such file or directory`.
1547+
_ if cfg!(windows)
1548+
&& fs::symlink_metadata(source)
1549+
.is_err_and(|e| e.kind() == io::ErrorKind::NotFound) =>
1550+
{
15471551
show_error!(
15481552
"{}",
15491553
translate!(

0 commit comments

Comments
 (0)